save
29 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have two variables:Var1=[1 2 3] and s='myData'. I am using assignin('base',s,Var1) to assign the contents of the text file as Var1 name. now I have another variable, myData=[1 2 3]. I wonder how I can save Var1 with the new name. Please let me know if I didn't ask it clearly.
Var1=[1 2 3]
s='myData'
assignin('base',s,Var1)
%now I have another variable, myData=[1 2 3] %now I want to save it with the new name with using the contents of s variable.
Save('C:\myData',assignin('base',s,Var1))
0 Kommentare
Akzeptierte Antwort
Paulo Silva
am 9 Jun. 2011
save(['C:\' s],s) %save the mat file with the same name as the variable
0 Kommentare
Weitere Antworten (2)
Krishna
am 9 Jun. 2011
Hi Hassan,
If you are trying to name your data you can do it using eval function as follows, FOR eg: T=[1;2;3;4;]; and you want to name this as 'testmatrix' then eval(strcat('testmatrix','= T;'));
you can do the same where T can be struct or a file etc.. Hope this helps.
2 Kommentare
Paulo Silva
am 9 Jun. 2011
please read this http://www.mathworks.com/support/tech-notes/1100/1103.html
Siehe auch
Kategorien
Mehr zu Whos finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!