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

1 回表示 (過去 30 日間)
Arsal15
Arsal15 2016 年 2 月 21 日
コメント済み: Arsal15 2016 年 2 月 21 日
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

採用された回答

Walter Roberson
Walter Roberson 2016 年 2 月 21 日
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);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by