Re: [Scilab-users] How to assign column data to mlist?
Hello, Le 11/07/2015 13:41, jaipur a écrit : When I already have column data, how shall I collect these data into a mlist? For example, I have 2 column data, data1=[11:20]'; data2=[21:30]'; I create a mlist, MyMlist = mlist(['M', 'field1', 'field2', 'field3']); I'd like to assign data1, data2 to field1, field2, and access them as MyMlist(3).field1 and so on. . What do you expect from MyMlist(3).field1 ? and from MyMlist.field1 ? and from MyMlist.field1(3)? Extractions must be defined for the M type. And size(MyMlist) or length(MyMlist) should be 10. I tried MyMlist.field1= data1; MyMlist.field2= data2; The result is size(MyMlist) does not work. . This is normal: when a new typed list is defined, all operations for it must be explicitely defined: here, %M_size() for size(), extraction, insertion, etc length(MyMlist) is 3. define %M_length() And MyMlist(1) indicate !M field1 field2 field3 ! MyMlist(2) indicate the values of data1 MyMlist(3) indicate the values of data2 Really? For these extractions, i get an error (for each). HTH Samuel ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] How to assign column data to mlist?
Thanks for your suggestion. Each element of data1 and data2 has, for example, individual's property like his height and weight. So, I want to treat as one element of mlist like MyMlist(3), MyMlist(3).field1, MyMlist(3).field2 when notice as individual. On the other hand, when I want to calculate mean value etc. of property, I'd like to treat as MyMlist.field1, MyMlist.field2(3:6) and so on. I understand overloading is the right way concerning mlist. But, is there simple way to create one structure without overloading fulfilling my wish above, when I have each property data, data1 and data2? -- View this message in context: http://mailinglists.scilab.org/How-to-assign-column-data-to-mlist-tp4032561p4032563.html Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] How to assign column data to mlist?
Le 12/07/2015 06:21, jaipur a écrit : Thanks for your suggestion. Each element of data1 and data2 has, for example, individual's property like his height and weight. So, I want to treat as one element of mlist like MyMlist(3), MyMlist(3).field1, MyMlist(3).field2 when notice as individual. On the other hand, when I want to calculate mean value etc. of property, I'd like to treat as MyMlist.field1, MyMlist.field2(3:6) and so on. I understand overloading is the right way concerning mlist. But, is there simple way to create one structure without overloading fulfilling my wish above, when I have each property data, data1 and data2? You may use a structures array instead, together with list2vec(..) after extraction of values of any scalar field. As well, do not hesitate to comment this thread http://bugzilla.scilab.org/11888, that claims for your request. Presently, it is not possible to do element-wise assignment on structures array. Free overloadable operators can't work with operands passed by reference, so can't be used for overloading some new types of assignment. Regards Samuel ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] How to assign column data to mlist?
Thank you for your suggestion. I posted to http://bugzilla.scilab.org/11888. -- View this message in context: http://mailinglists.scilab.org/How-to-assign-column-data-to-mlist-tp4032561p4032566.html Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] How to assign column data to mlist?
Hello, I am trying to understand what Jaipur/Tachihara aims to achieve and wondering why simple code such as shown below cannot meet his requirements: 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) Thanks and regards, Rafael -Original Message- From: users [mailto:users-boun...@lists.scilab.org] On Behalf Of Samuel Gougeon Sent: Sunday, July 12, 2015 9:50 AM To: International users mailing list for Scilab. Subject: Re: [Scilab-users] How to assign column data to mlist? Le 12/07/2015 06:21, jaipur a écrit : > Thanks for your suggestion. > > Each element of data1 and data2 has, for example, individual's property like > his height and weight. So, I want to treat as one element of mlist like > MyMlist(3), MyMlist(3).field1, MyMlist(3).field2 when notice as individual. > > On the other hand, when I want to calculate mean value etc. of property, I'd > like to treat as MyMlist.field1, MyMlist.field2(3:6) and so on. > > I understand overloading is the right way concerning mlist. > But, is there simple way to create one structure without overloading > fulfilling my wish above, when I have each property data, data1 and data2? You may use a structures array instead, together with list2vec(..) after extraction of values of any scalar field. As well, do not hesitate to comment this thread <http://bugzilla.scilab.org/11888> http://bugzilla.scilab.org/11888, that claims for your request. Presently, it is not possible to do element-wise assignment on structures array. Free overloadable operators can't work with operands passed by reference, so can't be used for overloading some new types of assignment. Regards Samuel ___ users mailing list <mailto:users@lists.scilab.org> users@lists.scilab.org <http://lists.scilab.org/mailman/listinfo/users> http://lists.scilab.org/mailman/listinfo/users ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
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 ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] How to assign column data to mlist?
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-boun...@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 ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] How to assign column data to mlist?
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 ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] How to assign column data to mlist?
Le 13/07/2015 23:53, Rafael Guera a écrit : Not sure of what M(i) should mean in a situation where the matrices have different sizes: The developer is responsible for his/her mlist design: * when initializing or assigning data, their respective sizes may be checked * if data with distinct sizes are allowed, extraction may - either foresee default values when some data are missing for some fields - or manage undefined values, as allowed in list and tlist Samuel ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] How to assign column data to mlist?
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" 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 ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users