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일

0 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

2015년 6월 29일

댓글:

2015년 6월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by