How do I save all of the workspace variables except for a certain specified variable under a specified name?
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I got an example from http://www.mathworks.co.uk/support/solutions/en/data/1-F4WH7N/index.html?product=SL&solution=1-F4WH7N:
>> clear;
>> a = 3; b = 4; c = 5; d = 6;
>> save test -regexp ^(?!(a|d)$).
however, I would like to save the workspace as 'filename2.mat', which is the second string in a cell array E, i.e. E=[filename1, filename2, filename3];
because it would be used in a loop ,so I cannot specify the name as 'filename2.mat'.
BTW, neither those codes would work:
filename=char(E(2));
save (filename -regexp ^(?!(a|d)$).)
save (filename,-regexp ^(?!(a|d)$).)
save (filename) -regexp ^(?!(a|d)$).
Anyone could help? Thanks!
0 Kommentare
Antworten (1)
per isakson
am 10 Mai 2013
Try
save( filename, '-regexp', '^(?!(a|d)$).' )
the values of the arguments should be strings
0 Kommentare
Siehe auch
Kategorien
Mehr zu Characters and Strings 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!