Re: [Scilab-users] Array of struct
Samuel GOUGEON wrote It looks to works as expected. It is hard to help you without knowning more about the structure that you use. Could you post some lines of code that fail and that could be copied/pasted for test? Samuel Thank you all for your answers and suggestions. I can't give away all of the code but the following should be enough to replicate the issue: You will see that it only takes the first element of temp in pts as opposed to the whole of the struct. In practice the size of temp will vary depending on the file being read, but each element will always have the same fields (partnumber, P and C), and the size of the matrices P and C doesn't change either. The size of pts will depend on the number of files in the directory being read (these operations are done in a loop, going through each file in a directory). Maybe pts($+1) = temp is not the correct way to append the whole of the struct in an existing struct, but I haven't found a way to do this so far. Update: just realised that pts($+1,:) = temp. Is that the correct way to do it? Thanks, Arnaud -- View this message in context: http://mailinglists.scilab.org/Array-of-struct-tp4026086p4026096.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] Array of struct
Maybe pts($+1) = temp is not the correct way to append the whole of the struct in an existing struct, but I haven't found a way to do this so far. Update: just realised that pts($+1,:) = temp. Is that the correct way to do it? //a : is actually needed, but here: pts($+1) = temp(:) Samuel ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] Array of struct
//a : is actually needed, but here: pts($+1) = temp(:) Sorry amiege, i have forgotten clearing pts before issuing this command, and its result is not the expected one. By the way, what's the expected result? Do you wish a) to add temp(1:$) as a whole, as a _single_ new element of pts(), or b) to add each element temp(i) as a new corresponding element in pts($+i), in a distributive way? In the latter case, the (whole) following does the job: pts = struct(); temp(1).partnumber = 1; temp(1).P = zeros(8,3); temp(1).C = zeros(96,5); temp(2).partnumber = 2; temp(2).C = zeros(96,5); temp(2).P = zeros(8,3); s = size(pts,*); st = size(temp,*); pts(s+1:s+st) = temp(:) // pts($+1:$+st) can't be used Samuel ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] Array of struct
pts(s+1:s+st) = temp(:) // pts($+1:$+st) can't be used, even with parentheses ($+1):($+st) // but pts($+(1:st)) can! : pts = struct(); temp(1).partnumber = 1; temp(1).P = zeros(8,3); temp(1).C = zeros(96,5); temp(2).partnumber = 2; temp(2).C = zeros(96,5); temp(2).P = zeros(8,3); st = size(temp,*); pts($+(1:st)) = temp(:) // works ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] Array of struct
Samuel GOUGEON wrote //a : is actually needed, but here: pts($+1) = temp(:) Sorry amiege, i have forgotten clearing pts before issuing this command, and its result is not the expected one. By the way, what's the expected result? Do you wish a) to add temp(1:$) as a whole, as a _single_ new element of pts(), or b) to add each element temp(i) as a new corresponding element in pts($+i), in a distributive way? I would prefer to have the whole of the struct temp to be pts($+1), so that pts(i) contains all the information related to the data file that has been parsed, so I think that's a). pts(i) would then be a struct which would match what temp is or was when it was constructed. I will try the various solutions suggested and report back which one works best. Thanks, Arnaud -- View this message in context: http://mailinglists.scilab.org/Array-of-struct-tp4026086p4026104.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] Array of struct
amiege wrote I would prefer to have the whole of the struct temp to be pts($+1), so that pts(i) contains all the information related to the data file that has been parsed, so I think that's a). pts(i) would then be a struct which would match what temp is or was when it was constructed. I will try the various solutions suggested and report back which one works best. Thanks, Arnaud seems to work. I then need to index into pts using pts(i,j) where i is the file number and j is the jth element of the original temp. I think that solves that question, unless someone tells me otherwise. Thanks again, Arnaud -- View this message in context: http://mailinglists.scilab.org/Array-of-struct-tp4026086p4026105.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] Array of struct
amiege wrote: I would prefer to have the whole of the struct temp to be pts($+1), so that pts(i) contains all the information related to the data file that has been parsed, so I think that's a). pts(i) would then be a struct which would match what temp is or was when it was constructed. I will try the various solutions suggested and report back which one works best. amiege wrote: seems to work. Not as a). For this, since you do not need that pts has some fields, a cell would be preferable (by the way, i did not know nor find any way to do it with pts as a struct). This will give: pts = cell() // A cell instead of a struct temp(1).partnumber = 1; temp(1).P = zeros(8,3); temp(1).C = zeros(96,5); temp(2).partnumber = 2; temp(2).C = zeros(96,5); temp(2).P = zeros(8,3); pts(size(pts,*)+1).entries = temp // pts($+1).entries addressing fails pts(size(pts,*)+1).entries = temp pts(2).entries Samuel ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
[Scilab-users] vatying color along a curve
Hello, I am trying to plot a curve using varying colors (or saturations) along the way. The curve is computed as a series of segments. To plot a segment beginning at (xd,yd) and ending at (xf,yf), I have tried the following plot([xd,xf],[yd,yf],foreground,3); This works, but, at each call of plot (thousands in my case) Scilab emits the following message: AVERTISSEMENT : Incorrect input : Color vector should be a 3x1 or 1x3 vector Further, I would like to use colors which do not belong to the default color table. If I do plot([xd,xf],[yd,yf],foreground,[3,3,3]); the program stops on the first call to plot with the following error message: addcolor : Type erroné de l'argument d'entrée n°1 : Une structure de données de type color_map attendue I then tried plot([xd,xf],[yd,yf],foreground,color_map(3)); the program stops on the first call to plot with the following error message: Variable non définie : color_map What is the correct syntax? I would like to choose a different color vector for each call of plot. Further, the help sometimes states that color vector elements must be integers from 0 to 256, sometimes reals between 0 and 1; which is correct ? Thank you in advance for your time and help. JP Grivet ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] vatying color along a curve
Hi. About colors see help color_list. You can set your own color with help of name2rgb or provide color directly: plot(cos(1:100),foreground,name2rgb('green')/255); or plot(cos(1:100),foreground,[0.8 0.75 0.75]); // I don't know the name of this color Stanislav -- View this message in context: http://mailinglists.scilab.org/Scilab-users-Format-legends-of-a-graph-as-a-2D-table-tp4025997p4026110.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