Using variable names for saving data

20 次查看(过去 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 CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by