フィルターのクリア

Using a Variable inside the name to save a file

1 回表示 (過去 30 日間)
Simona Pernischova
Simona Pernischova 2019 年 7 月 24 日
編集済み: Stephen23 2019 年 7 月 24 日
Hi all,
I would like to use a Variable that changes inside the name of a file to save.
the variable is "ID"
ID=P01
and I want to save a created figure as following:
saveas(gcf,'date_'[ID]'_task.jpg');
but that obviously doesn't work, and i dont know what the trick is :(

回答 (1 件)

Stephen23
Stephen23 2019 年 7 月 24 日
編集済み: Stephen23 2019 年 7 月 24 日
fnm = sprintf('date_%s_task.jpg',ID);
saveas(gcf,fnm);
Note that obtaining and referring to explicit graphics handles is more reliable than using gcf, gca, etc. and hoping that the current object is the one that you want to refer to.

カテゴリ

Help Center および File ExchangeGraphics Object Identification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by