- ‘saveas’ function: https://www.mathworks.com/help/matlab/ref/saveas.html
- Export Setup: https://www.mathworks.com/help/matlab/creating_plots/customize-figure-before-saving.html
Integrating the setting of the export setup in the code
50 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi guys,
I have set up my Figure very well in the "Export Setup". Is there now a possibility to execute the saved export style directly in the code and to save the figure automatically in the desired format (png)?
Unfortunately, after searching for a while, I have not been able to find a solution for this....
0 commentaires
Réponses (1)
Manikanta Aditya
le 19 Avr 2023
Modifié(e) : Manikanta Aditya
le 19 Avr 2023
Hi Max,
As per my understanding, you are interested to know if it is programmatically possible to set the options in ‘Export Setup’ and save the figure in desired format.
Here is an example showing how you can do it:
% Create a sample plot
x = 1:10;
y = sin(x);
plot(x, y);
% Apply the export setup
matlab.graphics.exportsetup.Format = 'png';
matlab.graphics.exportsetup.Width = '3in';
matlab.graphics.exportsetup.Height = '2in';
matlab.graphics.exportsetup.Resolution = '300';
% Save the figure in PNG format
filename = 'myplot.png';
saveas(gcf, filename);
Here ‘matlab.graphics.exportsetup’ property is used to apply setup to the current figure. You can customize the properties of ‘matlab.graphics.exportsetup’ object to match the settings you have saved in the export setup. The ‘saveas’ function is used to save the figure in desired format with the specified filename.
Please refer to the following documentation for more info on:
I hope this resolves the issue you were facing.
0 commentaires
Voir également
Catégories
En savoir plus sur Printing and Saving 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!