How to save whole work space with a new file name with every iteration.

1 vue (au cours des 30 derniers jours)
Arsal15
Arsal15 le 21 Fév 2016
Commenté : Arsal15 le 21 Fév 2016
I want to save my work space with a different file name for every iteration. ?
I am calling a function Hexagon so it runs for 20 seconds and it generates some output so I want to save work space of that function with a file name start with MS_Num and then MS_Num value everytime it takes.
if true
clc
clear all
close all
sizeL = 100;
radius = 10;
Num_MS = [1500 2000 3000 4000 5000 6000 7000 8000 9000 10000];
for i = 1 : 10
MS_Num = Num_MS(i);
Hexagon(sizeL,radius,MS_Num);
end
end
I will be happy if you can guide me accordingly. Thanks

Réponse acceptée

Walter Roberson
Walter Roberson le 21 Fév 2016
You cannot save the workspace of a different function than you are running in, not unless that other function is your immediate caller (though now that I think of it, that could be extended to any caller in the parent tree, though not easily.)
If you are in a function and you want to save its workspace for iteration #i then
savefile_name = sprintf('hexagon_results_%d.mat', i);
save(savefile_name);

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by