save ensure automatic renaming
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Wouter Verstraelen
am 7 Jun. 2019
Bearbeitet: Stephen23
am 7 Jun. 2019
I am running a script repeatedly each time changing a few parameters, each time evaluation takes at least a few hours. At the end of my code, I put
save('myfilename.mat').
Now, each time, I have to ensure I change myfilename to avoid any data gets overwritten. Is there a way to ensure that if 'myfilename.mat' already exists, matlab saves the second .mat file as 'myfilename(1).mat' etc?
2 Kommentare
Akzeptierte Antwort
Walter Roberson
am 7 Jun. 2019
There is no automatic way to do that. You can write your own code for the purpose.
filenum = 0;
while true
filenum = filenum + 1;
filename = sprintf('myfilename_%d.mat', filenum);
if ~exist(filename, 'file'); break; end
end
save(filename);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Types 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!