필터 지우기
필터 지우기

Integrating the setting of the export setup in the code

조회 수: 46 (최근 30일)
Max1234
Max1234 2023년 4월 13일
편집: Manikanta Aditya 2023년 4월 19일
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