[scilab-Users] mfprintf

Adrien Vogt-Schilb vogt at centre-cired.fr
Wed Jul 20 14:59:54 CEST 2011


On 20/07/2011 14:25, computidoo wrote:
> hello,
>
> and i want to have in the ascii
> a
> ======
> 1 1
> 1 1
> ======
>
> what is the line that i have to write
>
> best regard
> computidoo

Hi

i have some functions to save and load things this way (the comments are 
here for you, read them!)
this is not completely bulltetpruf, you should make sure to manage 
folders properly for instance
hope it helps

//I would recommend to drop the "===", so the file is much easier to 
parsefunctionmybetterexport(varname)matval=evstr(varname);[nm]=size(matval);output=emptystr(n+1,m);//n+3 
if you // output = emptystr(n+3,m); //if you really need the 
=====output(1,1)=varname;output(2:$,:)=string(matval);// output(3:$-1,:) 
= string(matval);// output([2 $],:) = 
"="write_csv(output,varname+".tsv")//you should be able to open the tsv 
file with excel, in a very convinient way. you can use any notepad 
tooendfunctionfoo=rand(3,5);//two ways to use the 
functionsmybetterexportfoomybetterexport("foo");//lets read the 
generated file[valtxt]=fscanfMat("foo.tsv")//this function will parse 
"foo.tsv" very very quickly//which allows : 
functionmybetterimport(varname)[valtxt]=fscanfMat(varname+".tsv")//very 
useful ! ifvarname~=stripblanks(txt,%t)//paranoid check, you could drop 
this an rely on the filenameerror("file corrupted")enddisp(varname+" 
will be loaded to scilab")execstr("["+varname+"]=return(val)")//if you 
want to understand this wizzard stuff, try "help execstr" and "help 
return", and also 
http://wiki.scilab.org/howto/global%20and%20local%20variablesendfunctionclearfoo//forgets 
foomybetterimportfoomybetterimport("foo")foo//this is total magic
regards,
Adrien Vogt-Schilb




















	

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


More information about the users mailing list