help-octave
[Top][All Lists]
Advanced

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

Re: How doyou vectorize pulling values out of a matrix?


From: Robert A. Macy
Subject: Re: How doyou vectorize pulling values out of a matrix?
Date: Mon, 24 Jul 2006 20:00:17 -0700

Thanks to all who answered!  There were three techniques
proferred.  

Of the three the fastest was to reshape mymatrix per Tom's
suggestion into a long vector and "jump" down to the final
index location.  Yes, it took some finagling to get to the
right value and in no way was intuitive at first.

The next fastest was sub2ind which took 1.8 times longer

The slowest, but easiest to use was diag(mymatrix(.,.))
It was 2.8 times slower.

Thanks again, found two new functions, didn't even know
existed.  

               - Robert - 

Note, my version of 2.1.50a does have sub2ind in it.  
Reluctant to change away from 2.1.50a  Would all the
functions I now use in gnuplot still work if I upgraded?  


On Mon, 24 Jul 2006 20:40:35 -0400
 "John W. Eaton" <address@hidden> wrote:
> It might matter in this case because sub2ind was added to
> Octave about
> 6 months after the 2.1.50 snapshot was made.  Since
> sub2ind is a .m
> file, you might be able to grab a copy from a newer
> version of Octave
> and use it with what you have.  OTOH, you might
> eventually want to
> consider upgrading to something more modern.
> 
> jwe



reply via email to

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