How to save figures directly to a folder without having them display?
    94 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    Zach Dunagan
 le 12 Déc 2017
  
    
    
    
    
    Commenté : Walter Roberson
      
      
 le 2 Août 2023
            I have a set of plots, in other words figures, that need to be saved directly to the folder. I have the code set up where it saves the figures to a folder, but they display and then close. I don't even want them to display, rather save directly to the folder. Can Someone write up a small example or at least tell me the commands needed?
0 commentaires
Réponse acceptée
  Chris Perkins
    
      
 le 14 Déc 2017
        Hi Zach,
When you create a figure, you can set the 'visibile' property to 'off', which will cause it not to display. Then anything you plot on that figure will also not be displayed.
Here is a brief example:
f = figure('visible','off');
plot(1:10); % Do whatever plotting you want to here
saveas(f,'savedFigure','jpg');
The figure will still be saved in your Workspace as 'f' after this, but MATLAB will not have displayed it in a figure window.
3 commentaires
  Walter Roberson
      
      
 le 2 Août 2023
				for t = 1 : 30
    f = figure('visible','off');
    plot(rand(1,10)); % Do whatever plotting you want to here
    filename = "savedFigure" + t + ".jpg";
    saveas(f, filename);
end
,,, except that in practice you would likely instead use
f = figure('visible','off');
for t = 1 : 30
    plot(rand(1,10)); % Do whatever plotting you want to here
    filename = "savedFigure" + t + ".jpg";
    saveas(f, filename);
end
or else
for t = 1 : 30
    f(t) = figure('visible','off');
    plot(rand(1,10)); % Do whatever plotting you want to here
    filename = "savedFigure" + t + ".jpg";
    saveas(f(t), filename);
end
Plus de réponses (0)
Voir également
Catégories
				En savoir plus sur Graphics Performance dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



