Save run a .m file and rename a file in a loop
1 次查看(过去 30 天)
显示 更早的评论
Hi. I want to ask. Is there anyway to run a .m file and rename a saved file by increment the number in the end of name, like version number in a loop, about 30 times. For example, I want to run A.m, and rename saved file results.mat as results1.mat. When another round, results.mat will rename as results2.mat, and so on.
0 个评论
采纳的回答
Walter Roberson
2017-7-6
oldname = 'results.mat';
for K = 1 : 30
run('A.m');
newname = sprintf('results%d.mat', K);
movefile(oldname, newname);
end
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 File Operations 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!