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

 Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 18 Okt. 2020
Bearbeitet: Ameer Hamza am 18 Okt. 2020

0 Stimmen

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 Kommentare

Vladimir Sovkov
Vladimir Sovkov am 18 Okt. 2020
Bearbeitet: Vladimir Sovkov am 18 Okt. 2020
Maybe, either i or id throughout but not both. Another way
filename=strcat('Trace_',num2str(i));
Ameer Hamza
Ameer Hamza am 18 Okt. 2020
@Vladimir, thanks for pointing out.
yusra Ch
yusra Ch am 18 Okt. 2020
Thank you guys for your help, I really appreciate it

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Fortran with MATLAB finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 18 Okt. 2020

Kommentiert:

am 18 Okt. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by