how can save different plot with different names file in loop use fullfile ?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Muhannad Saleh
am 11 Mär. 2021
Beantwortet: Bjorn Gustavsson
am 11 Mär. 2021
i have a loop have spectrogram to plot and i need save the plots with different names
for
...
...
spectrogram(M1,'yaxis')
filename = fullfile('path','file.jpg');
exportgraphics(gca,filename);
end
how can save plots with different file name
0 Kommentare
Akzeptierte Antwort
Bjorn Gustavsson
am 11 Mär. 2021
Simply modify the filename:
for idx_loop = % whatever you have
...
...
spectrogram(M1,'yaxis')
filename = fullfile('path',sprintf('file-%04d.jpg',idx_loop));
exportgraphics(gca,filename);
end
You can obviously modify the filename using any other changing parameter, but this should give you filenames of the type:
file-0001.jpg, file-0002.jpg etc. See help for sprintf and fprintf for more details of the string-generation you can utilize.
HTH
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!