How to save GUI plots
    7 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
I have done simulation in GUI, I dont know how to save that Plot now. How can I save it.
Respuestas (1)
  Luna
      
 el 30 de Mayo de 2019
        
      Editada: Luna
      
 el 30 de Mayo de 2019
  
      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 comentarios
  Walter Roberson
      
      
 el 30 de Mayo de 2019
				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
      
 el 30 de Mayo de 2019
				Yes, you are right. Thanks Walter! Now I definetely believe that you are a human :) :)
Ver también
Categorías
				Más información sobre Creating, Deleting, and Querying Graphics Objects en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


