MATLAB Answers

0

How to save GUI plots

faiza gul さんによって質問されました 2019 年 5 月 29 日
最新アクティビティ Luna
さんによって コメントされました 2019 年 5 月 30 日
I have done simulation in GUI, I dont know how to save that Plot now. How can I save it.

  3 件のコメント

Walter Roberson
2019 年 5 月 29 日
See saveas() and print() . Also if there is a toolbar then the upper left menu should provide you with a menu that permits you to save the figure in any of several formats.
faiza gul 2019 年 5 月 29 日
what should I write in saveas(), i have searching about this but no luck.
ANd there is no toolbar thats appearing in GUI plot. In normal plot there is toolbar but not in GUI plot.
Walter Roberson
2019 年 5 月 29 日

サインイン to comment.

タグ

1 件の回答

Luna
回答者: Luna
2019 年 5 月 30 日
編集済み: Luna
2019 年 5 月 30 日

Before you plot, you should save your figure handle into a variable so that you can put it as an input of saveas function.
Instead of using gcf, assigning handles into variables is useful and prevents conflicts when you are dealing with multiple plots with multiple figures.
(Because gcf only returns the last focused figure object)
Here is example:
hFig = figure; % hFig is figure handle.
x = 0:10;
y = 10:20;
plot(x,y);
saveas(hFig, 'myFigure.fig');
% or
saveas(hFig, 'myFigure.png');

  2 件のコメント

Walter Roberson
2019 年 5 月 30 日
Small improvement:
hFig = figure; % hFig is figure handle.
ax = axes('Parent', hFig);
x = 0:10;
y = 10:20;
plot(ax, x,y);
saveas(hFig, 'myFigure.fig');
% or
saveas(hFig, 'myFigure.png');
Otherwise there are some cases where the figure could lose focus between the time the figure was created and the time the plot was created, which would lead to the plot going elsewhere.
Luna
2019 年 5 月 30 日
Yes, you are right. Thanks Walter! Now I definetely believe that you are a human :) :)

サインイン to comment.



Translated by