[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cell{1:5}=1 not working for me!!!
From: |
Juan Pablo Carbajal |
Subject: |
Re: cell{1:5}=1 not working for me!!! |
Date: |
Wed, 30 May 2012 19:26:34 +0200 |
On Wed, May 30, 2012 at 7:00 PM, Francesco Potortì <address@hidden> wrote:
>>> octave:1> cell{1:5}=1
>>> error: invalid assignment to cs-list outside multiple assignment.
>>> error: assignment to cell array failed
>>> error: assignment failed, or no method for `<unknown type> = scalar'
>>>
>>> It used to work in past versions. This code is from an old functioning
>>> script from me. What happened?
>>
>>If it used to work, it was a bug. Use () instead of {} to index cells
>>with assignment.
>
> I have this code:
>
> 1: s = cell(sn);
> 2: for txi = 1:sn
> 3: for rxi = 1:sn
> 4: s{txi,rxi} = NA(mt,1);
> 5: x = t(ti);
> 6: y = rx(ti,rxi);
> 7: s{txi,rxi}(x) = y;
> 8: endfor
> 9: endfor
>
> I seem never to really understand how cells work. Or maybe I use them
> so widely apart in time that I forget...
>
> If I change row 4 to index s with () rather than {}, it works. If I
> change row 7 the same way, I get "error: () must be followed by . or
> close the index chain".
>
> I understand neither the first nor the second fact.
>
> --
> Francesco Potortì (ricercatore) Voice: +39.050.315.3058 (op.2111)
> ISTI - Area della ricerca CNR Mobile: +39.348.8283.107
> via G. Moruzzi 1, I-56124 Pisa Fax: +39.050.315.2040
> (entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
The first fact is easy to understand: you can assign to a cell with
any of the operators () or {}.
The second fact is due to the output of the two operators. Try this
s = cell(3);
s(2,2) = NA(1,3);
s{2,2}
s(2,2)
As you can seem, the call with {2,2} returns an array while the call
with (2,2) returns a cell. So, for some reason (do not ask me!) when
you get the cell you cannot indent with ().
s(2,2)(2) = 1 # fails
#Though this works
a = s(2,2) # a is a cell
a(2) = 1
--
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/
- cell{1:5}=1 not working for me!!!, oxy, 2012/05/30
- Re: cell{1:5}=1 not working for me!!!, Jordi Gutiérrez Hermoso, 2012/05/30
- Re: cell{1:5}=1 not working for me!!!, Francesco Potortì, 2012/05/30
- Re: cell{1:5}=1 not working for me!!!,
Juan Pablo Carbajal <=
- Re: cell{1:5}=1 not working for me!!!, Francesco Potortì, 2012/05/31
- Re: cell{1:5}=1 not working for me!!!, Jordi Gutiérrez Hermoso, 2012/05/31
- Re: cell{1:5}=1 not working for me!!!, oxy, 2012/05/31
- Re: cell{1:5}=1 not working for me!!!, Jordi Gutiérrez Hermoso, 2012/05/31
- Re: cell{1:5}=1 not working for me!!!, oxy, 2012/05/31
- Re: cell{1:5}=1 not working for me!!!, Jordi Gutiérrez Hermoso, 2012/05/31
Re: cell{1:5}=1 not working for me!!!, c., 2012/05/30