How to save GUI plots

조회 수: 6 (최근 30일)
passioncoding
passioncoding 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
passioncoding
passioncoding 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
Walter Roberson 2019년 5월 29일

댓글을 달려면 로그인하십시오.

답변 (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
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
Luna 2019년 5월 30일
Yes, you are right. Thanks Walter! Now I definetely believe that you are a human :) :)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by