[Scilab-users] How to assign column data to mlist?

Samuel Gougeon sgougeon at free.fr
Tue Jul 14 12:21:10 CEST 2015


Le 13/07/2015 23:53, Rafael Guera a écrit :
>
> Samuel,
>
> Thanks for the detailed explanation.
>
> Not sure of what M(i) should mean in a situation where the matrices 
> have different sizes:
>
> data1=ones(10,4);
>
> data2=zeros(5,3);
>
> M=mlist(['V','field1','field2']);
>
> M.field1=data1;
>
> M.field2=data2;
>
> or when the mlist fields are N-dimensional with different dimensions 
> and/or sizes.
>
> PS:
>
> why not defining M(i) = M.field#i ?
>
Do you mean the ith field?
Why not. But mlists are designed to be array-oriented, as cells and 
structures are:
 From help mlist:
" mlist object is very similar to tlist object. The only difference 
concerns the extraction and
  insertion syntax: if M is an mlist, for any index i which is not a 
field name, M(i) is no more the
  i-th field of the list."

If you wish (i) selecting a field, how will you select a component of 
the M array?

I mean, using i to select a field puts two way for the same purpose 
(selecting a field, either by its name, or by its index), and removes a 
way to select a component from the array.


What you wish looks like a simple tlist, with index just shifted by one 
to ignore the identification vector:
-->t = tlist(["test" "r" "b" "p"], %pi, %f, %z)
  t  =
        t(1)
!test  r  b  p  !
        t(2)
     3.1415927
        t(3)
   F
        t(4)
     z

-->t(3)
  ans  =
   F

-->t.b
  ans  =
   F

Samuel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20150714/9760b2a9/attachment.htm>


More information about the users mailing list