help-octave
[Top][All Lists]
Advanced

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

Re: array cross sections


From: John W. Eaton
Subject: Re: array cross sections
Date: Tue, 24 Aug 2004 15:24:05 -0400

On 24-Aug-2004, Mike Miller <address@hidden> wrote:

| Two questions...
| 
| First, isn't this a more efficient way to get 'v'?...
| 
| a(find(a<0.5))

I think this should be better:

  a(a<0.5)

since it avoids calling find, but it could also end up being slower
for very large matrices since it requires forming an mask array that
is the same size as the original matrix.

| ...and does that require do_fortran_indexing = 1?

No.

| 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))

No, there is only

  i = find (x)

  [i, j] = find (x)

  [i, j, v] = find (x)

in Matlab and Octave.  The preferred method is apparently to use a
single index returned from find.  The i,j,k,... indices aren't really
useful by themselves.  For example, if you do

  [i, j, v] = find (x);

Then x(i,j) is only equivalent to v if i and j are empty or scalar
values.

jwe



-------------------------------------------------------------
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]