saving workspace of each pair of variable in a loop

11 ビュー (過去 30 日間)
Samson
Samson 2020 年 10 月 24 日
コメント済み: Samson 2020 年 10 月 26 日
Hello,
I help. I have a loop where I take each pair of variables and run. However, I want to save the workspace of each pair after each iterations. see example below:
iteration = 10
for ii = 1: length (X)
for jj = 1: length (Y)
display (['ii is', num2str (ii), 'and jj is', num2str (jj)])
%%% Function Call
end
let say X = 1 2 3
y = 5 6 7
I want to save the workspace for each pair. For instance, to save ii = 1 and jj = 5, etc
  2 件のコメント
Mathieu NOE
Mathieu NOE 2020 年 10 月 26 日
hello
you want to save all variables in a mat file for each iteration ?
or you prefer to generate a matrix / matrix of cells for all iterations and then save evrything in one file ?
Samson
Samson 2020 年 10 月 26 日
you want to save all variables in a mat file for each iteration? = yes. saving each pair of the iteration in a worspace. from the example of the data I gave for X and Y. I would love to see 9 workspaces

サインインしてコメントする。

採用された回答

Stephen23
Stephen23 2020 年 10 月 26 日
for ii = 1:numel(X)
for jj = 1:numel(Y)
... your code
fnm = sprintf('workspace_%d_%d.mat',ii,jj);
save(fnm)
end
end
  3 件のコメント
Stephen23
Stephen23 2020 年 10 月 26 日
@Samson: please remember to accept my answer if it helped you!
Samson
Samson 2020 年 10 月 26 日
Thanks!. I really appreciate

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by