How to save fig in a different folder

49 ビュー (過去 30 日間)
Valeria Leto
Valeria Leto 2021 年 11 月 10 日
コメント済み: Valeria Leto 2021 年 11 月 10 日
Hi! How can I make the folder where I want to save my figure vary?
This line works but I would like to create a variable for the folder so that I could decide where to store my fig.
savefig(figure(1),[pwd '/results/h.fig'],'compact');
I tried with fullfile but I think I used it in the wrong way.
Thanks

採用された回答

dpb
dpb 2021 年 11 月 10 日
mydir='yourfullyqualifiedpath';
savefig(figure(1),fullfile(mydir,'results','h.fig'),'compact');
The above also has the hardcoded filename 'h.fig' which isn't all that flexible; depending on the intended use consider uiputfile to let the user select the location interactively.
There are many possibilities in creating automagic naming systems; just have to decide what it is you really want and that fits the particular use pattern.
  1 件のコメント
Valeria Leto
Valeria Leto 2021 年 11 月 10 日
Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeModeling についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by