help-octave
[Top][All Lists]
Advanced

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

Re: array cross sections


From: Mike Miller
Subject: Re: array cross sections
Date: Tue, 24 Aug 2004 14:07:07 -0500 (CDT)

On Tue, 24 Aug 2004, Geraint Paul Bevan wrote:

Have a look at the 'find' function. You can use it to extract elements which meet some criteria. For example, to get all the elements of a 3x3 matrix which are less than 0.5:

octave> a = rand (3,3)
a =

~  0.81472  0.83501  0.91338
~  0.13548  0.12699  0.22103
~  0.90579  0.96887  0.63236

octave> [i,j,v] = find (a .* (a<0.5))


Two questions...

First, isn't this a more efficient way to get 'v'?...

a(find(a<0.5))

...and does that require do_fortran_indexing = 1?


Second question. How does "find" work with higher-dimensional arrays? Does one do this sort of thing with a three-diminsional array?...

[i,j,k,v] = find(a .* (a<0.5))

Best

Mike



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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