exportgraphics dynamic file name

조회 수: 20(최근 30일)
Pelajar UM
Pelajar UM 2022년 3월 22일
댓글: Ive J 2022년 3월 22일
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

채택된 답변

Ive J
Ive J 2022년 3월 22일
% 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
Ive J
Ive J 2022년 3월 22일
Glad it works
cheers!

댓글을 달려면 로그인하십시오.

추가 답변(0개)

범주

Find more on Printing and Saving in Help Center and File Exchange

태그

Community Treasure Hunt

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

Start Hunting!

Translated by