help-octave
[Top][All Lists]
Advanced

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

OOPS (RE: 3D Arrays in Octave ??)


From: Ted Harding
Subject: OOPS (RE: 3D Arrays in Octave ??)
Date: Mon, 04 May 1998 10:44:49 +0100 (BST)

On 04-May-98 Ted Harding wrote:
> On 04-May-98 Peter Biechele wrote:
>> Is it possible to have 3D arrays in Octave (like in Matlab) ?? That
>> means arrays with more than 2 indices ?
>> 
>> e.g.    an Array of Matrices like A(:,:,1:10) ???
> 
> It does not exist as yet, as far as I know; but I gather it is "on the list".
> 
> Meanwhile, it is possible to simulate multi-dimensional arrays by computing
> an
> index into a linear array; the whole tangle can conveniently be stored in a
> structure.
> 
> E.g. an array A has 3 dimensions A(1:3,1:5,1:4).
> 
> A.ndim = 3;
> A.dims = [5 7 6];  OOOPSSS!!!
  A.dims = [3 5 4];  is MUCH better
> A.elems = ...
>  [111 112 113 114 121 122 123 124 ... 151 152 153 154 ... 351 352 353 354];
> 
> function elem(A,i,j,k) = ...
> A.elems(k + A.dims(3)*(j-1) + A.dims(3)*A.dims(2)*(i-1))
> 
> This can obviously be extended to any number of dimensions.
> 
> Hope this helps,
> Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Date: 04-May-98                                       Time: 10:44:49
--------------------------------------------------------------------



reply via email to

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