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

Rafael Guera jrafaelbguerra at hotmail.com
Mon Jul 13 23:53:44 CEST 2015


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 ?
 
Regards,
Rafael
 
From: users [mailto:users-bounces at lists.scilab.org] On Behalf Of Samuel Gougeon
Sent: Monday, July 13, 2015 9:37 PM
To: International users mailing list for Scilab.
Subject: Re: [Scilab-users] How to assign column data to mlist?
 
Hello Rafael,

Le 13/07/2015 22:18, Rafael Guera a écrit :
.../... 


data1=[11:20]';
data2=[21:30]'; 
M = mlist(['V', 'field1', 'field2']);
M.field1 = data1;
M.field2 = data2;
disp(M)
printf("\n\n");
M.field1(2) = %e; // individual element assignment
M.field2(3:6) = %pi; // sub-array assignment
printf("%10.3f  %10.3f\n", M.field1, M.field2);
 
Also could someone explain why command “M(3)” produces errors and overloading is
required? (using Scilab 5.5.2 in Win7)
.
M being a M-list, M(3) should extract the third component of M table(s), so
data1(3) and data2(3).
But you have to specify how you wish to display it:
 * like [data1(3) data2(3) ] ?  
 * like [data1(3) ; data2(3) ] ? Then beware that the format of M(3:4)... must
be managed.
 * like list(data1(3), data2(3)) ? Then what would return M(3:4)?
 * like a struct s.data1 = data1(3) ; s.data2 = data2(3) ?
etc.
The same questions must be answered for insertion and extraction:
M(3) = [ %pi %e]  // should distribute and assign %pi data1(3) and %e to
data2(3)
When you insert content, you must check that .data1 and .data2 keep the same
size..
M(3:5) could return either a structure array, or a cell array, or a matrix...
The developper must choose according to the purpose that is followed...

HTH 
Samuel



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


More information about the users mailing list