running a loop and saving separate files
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi I am running a loop and saving each file separately.
The syntax I am using is
for i = 1:10
RUN PROGRAM
save(sprintf('datafile_%02d',i), 'phi')
end
So this means I am expecting all the phi's to be saved in different filenames. But I only get the most recent (overwritten?) and I do not get 10 separate files.
댓글 수: 0
채택된 답변
Image Analyst
2015년 12월 9일
No, i is changing so the filename is changing. Try to split it up
for k = 1 : 10
% code to RUN PROGRAM and change phi...
% Now save this phi in a new file.
filename = sprintf('datafile_%02d.mat', k);
message = sprintf('About to save phi into new file %s.', filename);
uiwait(helpdlg(message));
save(filename, 'phi');
end
Now see if the filenames are all the same or different.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!