如何将 .fig 文件中的图形保存为具有更高 dpi 的图像?

How can I save a figure in a .fig file as an image with higher dpi?

我有一个图形文件 (.fig),我想将其另存为 900 dpi TIFF 文件。

通常情况下,如果我自己创建情节:

figure;
plot(x,y);

然后命令:

print(gcf,'test.tif','-dpng','-r900');

会产生我想要的图像。但是,我只有 .fig 文件,而 MATLAB 无法通过关键字 gcf 识别绘图 window。有什么方法可以从 .fig 文件中保存高分辨率图像?

函数gcf simply returns the current figure handle, so if you've recreated the figure by opening your .fig file with openfig,它应该可以工作。以下示例以 900 dpi 的分辨率创建两个相同的 TIFF 文件,一个在保存 .fig 之前,一个在加载 .fig 之后:

surf(peaks);           % Create a surface plot
print(gcf, 'before_save.tif', '-dpng', '-r900');  % Save figure as an image
savefig('peaks.fig');  % Save figure in a .fig file
close(gcf);            % Close figure

openfig('peaks.fig');  % Recreate figure from .fig file
print(gcf, 'after_save.tif', '-dpng', '-r900');  % Save new figure as an image