help-octave
[Top][All Lists]
Advanced

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

Re: Toy NDArray example


From: Keith Goodman
Subject: Re: Toy NDArray example
Date: Wed, 18 Jan 2006 15:28:38 -0600

On 1/18/06, David Bateman <address@hidden> wrote:
> I'd think the following example is something like what you want

Nice example. Thank you. Pairing a bunch of toy m-functions with the
corresponding oct-functions would make a nice document.

Since I can only index a NDArray with a single index, how do I pull
out an entire 2D slice of a 3D array?

n = [3 2 4];
x = rand(n);

I want y = x(:,:,j), so in an oct function would I have to do the equivalent of

ind = (j - 1)*n(1)*n(2) + (1:(n(1)*n(2)));
y = x(ind);
y = reshape(x,n(1),n(2));

or if reshape is not available loop over the rows and columns of y?



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