exportgraphics dynamic file name

9 Ansichten (letzte 30 Tage)
Pelajar UM
Pelajar UM am 22 Mär. 2022
Kommentiert: Ive J am 22 Mär. 2022
What's the correct syntax if you want to name the files dynamically when using exportgraphics?
I have a cell array A with 16 titles in each columns that are assigned to the colorbar string. I want to use the same titles to name the files.
for k = 1:16
%rest of the code
c = colorbar;
c.Label.String = string (A (:,k));
exportgraphics(gcf, string (A(:,k)) '.png' ,'Resolution',DPI) %this doesn't work
end

Akzeptierte Antwort

Ive J
Ive J am 22 Mär. 2022
% A = {'name1', ...}
for k = 1:16
%rest of the code
c = colorbar;
c.Label.String = A{k};
exportgraphics(gcf, string(A{k}) + ".png" ,'Resolution',DPI) %this doesn't work
end
You could also use strcat, join or similar functions.
  10 Kommentare
Pelajar UM
Pelajar UM am 22 Mär. 2022
Exactly what I was looking for. Thanks a lot!
Ive J
Ive J am 22 Mär. 2022
Glad it works
cheers!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks 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!

Translated by