help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to extract the diagonal entries out of a matrix


From: John W. Eaton
Subject: Re: how to extract the diagonal entries out of a matrix
Date: Sat, 7 Feb 2009 01:35:25 -0500

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]