Using variable names for saving data

18 ビュー (過去 30 日間)
Sudipta Ray
Sudipta Ray 2015 年 6 月 29 日
コメント済み: Sudipta Ray 2015 年 6 月 30 日
I am running a for loop for parametric sweep. After each loop, the data is to be saved within a .mat file using the 'save' command. How do I provide the function names so that each parameter gets its own .mat file after each loop completion?

採用された回答

Walter Roberson
Walter Roberson 2015 年 6 月 29 日
for K = 1 : 20
filename = sprintf('data%04d.mat', K);
save(filename, 'VariableName');
end
If you have more than 9999 iterations then increase the 4 to the maximum number of digits you need.
  1 件のコメント
Sudipta Ray
Sudipta Ray 2015 年 6 月 30 日
Thank you Walter. The parametric sweep is for not more than 10 values, so the last part is not an issue.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by