On 6-Feb-2009, David Doria wrote: | A = rand(3,3); | B = diag(A); Be careful with diag on arbitrary matrices. If your matrix happens to sometimes be a vector with more than one element, then diag does something completely different. For example, try diag (rand (2, 3)) diag (rand (1, 3)) You can thank Cleve for this (mis)feature. jwe