Integrating the setting of the export setup in the code

50 visualizaciones (últimos 30 días)
Max1234
Max1234 el 13 de Abr. de 2023
Editada: Manikanta Aditya el 19 de Abr. de 2023
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....

Respuestas (1)

Manikanta Aditya
Manikanta Aditya el 19 de Abr. de 2023
Editada: Manikanta Aditya el 19 de Abr. de 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.

Categorías

Más información sobre Printing and Saving en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by