exportgraphics dynamic file name

14 次查看(过去 30 天)
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 个评论
Pelajar UM
Pelajar UM 2022-3-22
Exactly what I was looking for. Thanks a lot!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by