フィルターのクリア

Save and close figure in Matlab

25 ビュー (過去 30 日間)
Konstantinos
Konstantinos 2015 年 3 月 28 日
編集済み: J Yadav 2018 年 4 月 3 日
My code produces 1 figure after each iteration. The problem is that, I have to run my code 1000 times, which means 1000 iterations.Therefore, I end up having 1000 open figure windows.Is there any command (or piece of code), that I can use in matlab in order to automatically save each figure produced in each iteration in a certain folder, and then close the figure window before the next iteration begins?

回答 (2 件)

Adam
Adam 2015 年 3 月 28 日
編集済み: Adam 2015 年 3 月 28 日
doc savefig
Although quite why you would want to save 1000 figures is another matter. You could just produce the figures on demand when you are going to actually look at them.
close( hFig )
closes the figure with handle hFig.
  2 件のコメント
Konstantinos
Konstantinos 2015 年 3 月 28 日
could you please explain a little more these 2 commands ? i.e. if I have one figure with the name "figure1" and I want to save it in the folder "default", what these commands would be ?
Adam
Adam 2015 年 3 月 28 日
編集済み: Adam 2015 年 3 月 28 日
I haven't used them myself, I just did exactly the search I would have assumed you could have done, but the help page should be pretty explicit as to how you use them. You just supply a figure handle and a filename (with full path if you don't want it to land in whatever the current directory is) and it will save the file.
close( hFig )
will close the figure. I'm not sure what more I can explain about that.
The thing you need for both of those though is to have opened your figure using:
hFig = figure;

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


J Yadav
J Yadav 2018 年 4 月 3 日
編集済み: J Yadav 2018 年 4 月 3 日
Hi, this link might be of help.
https://uk.mathworks.com/matlabcentral/answers/285548-saving-figures-in-matlab?s_tid=srchtitle

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by