[Scilab-users] How to assign column data to mlist?
jrafaelbguerra at hotmail.com
jrafaelbguerra at hotmail.com
Tue Jul 14 15:49:46 CEST 2015
Hi Samuel,
Thanks for shedding light about these less well documented yet advanced features of the Scilab language.
Best regards
Rafael
Sent by Outlook for Android
From: Samuel Gougeon
Sent: Tuesday 14 July 13:22
Subject: Re: [Scilab-users] How to assign column data to mlist?
To: International users mailing list for Scilab.
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
On Tue, Jul 14, 2015 at 3:22 AM -0700, "Samuel Gougeon" <sgougeon at free.fr> wrote:
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/c5b6097a/attachment.htm>
-------------- next part --------------
_______________________________________________
users mailing list
users at lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users
More information about the users
mailing list