Put a variable in a file title name

4 次查看(过去 30 天)
Hello,
I want to run a for loop that has an id=1:100 and at the end of each iteration I want matlab to save the results under a file name "Trace_id". So at the end of the programe I will have files called Trace_1 , Trace_2 ,etc...
Thank you

采纳的回答

Ameer Hamza
Ameer Hamza 2020-10-18
编辑:Ameer Hamza 2020-10-18
Something liks this
for id=1:100
% do your processing
M; % matrix to write to file
filename = sprintf('Trace_%d', id);
writematrix(M, filename)
end
  3 个评论
Ameer Hamza
Ameer Hamza 2020-10-18
@Vladimir, thanks for pointing out.
yusra Ch
yusra Ch 2020-10-18
Thank you guys for your help, I really appreciate it

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by