[scilab-Users] Using a cell entry to access part of a matrix

Iai Masafumi ax iai at axelspace.com
Mon Nov 7 23:19:19 CET 2011


Thanks for your reply. I wanted to use a cell array to manage a lot of
variable in my code which is more complicated.

I guess I have to put my question in a different way:

After running the code below, type(II(1)) returns 17 while type(ii)
returns 1. According to the help, 1 means "real or complex constant
matrix". 17 means "matrix oriented typed list (mlist)". How do I convert
II(1) into a "real or complex constant matrix"?


I expected II(1) would return a matrix essentially identical as ii
because I stored ii into the first entry of a cell array, II, by letting
II.entries(1)=ii. But obviously what I expected was not the case.



(2011/11/07 17:15), Adrien Vogt-Schilb wrote:
> Hi
> 
> why don't you just
> 
> y(ii(1)) ?
> 
> 
> On 07/11/2011 02:43, Iai Masafumi ax wrote:
>> Hi,
>>
>> Could anyone tell me if, in the codes below, there is any way to make
>> "y(II(1))" work without error, just like "y(ii)"? I wanted to access a
>> part of a matrix by using an entry of a cell. I think it is a pretty
>> intuitive way of using a cell.
>>
>> //--------------------------
>> y=[100:110]
>> ii=[1 3 5 7];
>> jj=[2 4 6 8];
>> y(ii)   // OK. This is an ordinary way.
>>
>> II=cell(2,1);
>> II.entries(1)=ii;
>> II.entries(2)=jj;
>>
>> II(1)
>> y(II(1)) //<-- ERROR
>>
>> y(II.entries(1)) // OK. But not as concise as I see the benefit of using
>> cells.
>> //--------------------------
>>
>>
>>
>> Thanks,
>> Iai
> 
> 
> -- 
> Adrien Vogt-Schilb (Cired)
> Tel: (+33) 1 43 94 *73 77*



More information about the users mailing list