[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: multi-dimensional matrix
From: |
Nathan Weisz |
Subject: |
Re: multi-dimensional matrix |
Date: |
Tue, 19 Aug 2003 08:43:23 +0200 |
Hi Weijun,
I just asked the same question a couple of days ago.
http://www.octave.org/octave-lists/archive/help-octave.2003/
msg01339.html
Got no answer however. :-(
So when I try this (as I would in Matlab) ...
octave:34> a=rand(2)
a =
0.493654 0.072149
0.024741 0.886199
octave:35> a(:,:,2)=rand(2)
... I get following error message:
error: invalid number of indices (3) for indexed assignment
error: assignment failed, or no method for `matrix = matrix'
error: evaluating assignment expression near line 35, column 9
So my non-expert guess is: no, a multi-dimensional matrix does not
work. But Perhaps someone else more experienced could comment on that.
Don't know if it helps you, but I temporarily solved my problem using
cells instead.
octave:36> b=cell(1,2); %define size of cell
octave:37> b{1,1}=rand(2);
octave:38> b{1,2}=rand(2);
octave:39> whos
*** local user variables:
prot type rows cols name
==== ==== ==== ==== ====
rwd cell 1 2 b
octave:45> b
b =
{
[1,1] =
0.70743 0.84567
0.33874 0.35939
[1,2] =
0.84809 0.51944
0.62300 0.88953
}
Yet operations over e.g. a third dimension (e.g., Matlab: mean(a,3)),
would be a little bit awkward and would need something like a "for i =
1:..."-statement. Or am I wrong??
Best,
Nathan
-------------------------------------------------------------
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
-------------------------------------------------------------