Filter löschen
Filter löschen

Integrating the setting of the export setup in the code

46 Ansichten (letzte 30 Tage)
Max1234
Max1234 am 13 Apr. 2023
Bearbeitet: Manikanta Aditya am 19 Apr. 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....

Antworten (1)

Manikanta Aditya
Manikanta Aditya am 19 Apr. 2023
Bearbeitet: Manikanta Aditya am 19 Apr. 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.

Kategorien

Mehr zu Printing and Saving finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by