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!