[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: multi-dimensional matrix
From: |
Weijun Zhu |
Subject: |
Re: multi-dimensional matrix |
Date: |
Tue, 19 Aug 2003 00:09:28 -0700 |
Nathan,
Thanks for your reply.
I tried the cell but did not work out on my machine.
What version of Octave are you using?
I got the following errors:
octave:29> b=cell(2,2);
octave:30> b{1,1}=rand(2)
error: range error
error: T& Array2<T>::checkelem (0, -1): range error
error: evaluating assignment expression near line 30, column 7
octave:30>whos
*** local user variables:
prot type rows cols name
==== ==== ==== ==== ====
rwd cell - - b
Weijun.
----- Original Message -----
From: "Nathan Weisz" <address@hidden>
To: "Weijun Zhu" <address@hidden>
Cc: "help-octave" <address@hidden>
Sent: Monday, August 18, 2003 11:43 PM
Subject: Re: multi-dimensional matrix
> 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
-------------------------------------------------------------