我最近一直在尝试在 MATLAB 中创建一个自定义大小的图形,并使用 saveas 函数自动保存它。特别是,我在以我创建的大小保存文件时遇到问题。粗略地说,我的代码如下:
mygraph = figure('Position',[1,20,1280,1024]);
% creates a figure positioned 1 px from the left of the screen
% 20 px from the bottom of the screen
% that is 1280 px in length and 1024 px in height
% some code to create graph
saveas(mygraph,'mygraphfilename','emf')
% saves figure as mygraphfilename.emf.
到目前为止,我的代码运行良好,因为它可以在我的屏幕上创建自定义大小的图形,但它似乎将图片本身保存为默认大小。奇怪的是,如果我不使用 saveas 功能并手动保存图形,那么图像会保留其大小。
为澄清起见,我目前将图表保存为 emf,但如果工作正常,我也愿意使用 jpg/png/bmp。