Integrating the setting of the export setup in the code

48 次查看(过去 30 天)
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....

回答(1 个)

Manikanta Aditya
Manikanta Aditya 2023-4-19
编辑:Manikanta Aditya 2023-4-19
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.

类别

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