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: David Doria
Subject: Re: how to extract the diagonal entries out of a matrix
Date: Fri, 6 Feb 2009 13:02:49 -0500

A = rand(3,3);
B = diag(A);

Dave

On Fri, Feb 6, 2009 at 1:01 PM, Edward <address@hidden> wrote:
> Hi,
>
> For example, there is a matrix like:
>
> [ 1 2 3 4
>   5 6 7 8
>   3 5 7 0
>   4 8 2 5 ]
> and I want to get the diagonal elements out of the matrix and make into a
> vector: [ 1 6 7 5]  .
>
> I know I could write some lines to do it, but I just want to know if there
> is a built-in function can do the job. Thank you.
>
> --
> Edward
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
>
>



-- 
Thanks,

David


reply via email to

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