[Scilab-users] save : save a list of variable don't work

Antoine Monmayrant antoine.monmayrant at laas.fr
Tue Oct 14 15:05:15 CEST 2014


On 10/14/2014 02:50 PM, Quentin Mazué wrote:
> hello,
>
>
> Antoine Monmayrant wrote
>> This is what you want to do I think:
>>
>> save(pwd()+"\saveInSodFormat.sod",'a','b','c','d');
> Yes it is. However in my script, the variable var2save could contain 1,2, or
> 100 variables. The number of variables is never the same. So I have another
> script that fill the variable var2save with the name of the variable I want
> to save and then I want to save this variables with their own values. (here
> variables a,b,c and d are only an example)
>
> If you use the function loadmatfile("saveInMatFormat.mat"), you will load
> a=1;
> b=2;
> c=[1;2;3;4;8;9;6];
> d = [7];
> *It is what I want.*
>
> However if you use the function load("saveInSodFormat.sod"), you will load
> var2save  = !a  b  c  d  !
> *I don't want this*
>
>
> Summary :
> 2 different save function lead to 2 different save data although it was
> expected to be the same.
No, this is where you are wrong:
"two different save functions that have different syntaxes and thus lead 
to 2 different saved data, as expected from what is written in the help 
page."
savematfile/loadmatfile are here for compatibiltily with matlab and use 
matlab file format.
save/load are using the new native scilab file format (based on open 
spec hdf5).

If you want to use save with a varying number of variables, you can do 
something like this:
//assuming that var2save is a 1d vector of names of the variables to save:
execstr('save(pwd()+''\saveInSodFormat.sod'','+strcat(var2save+',')+')')

Cheers,

Antoine

>
> Regards
> Quentin Mazué
>
>
>
> --
> View this message in context: http://mailinglists.scilab.org/save-save-a-list-of-variable-don-t-work-tp4031334p4031336.html
> Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>



More information about the users mailing list