本文介绍了将终端下的Matlab隐形图像保存为相同大小的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是SSH连接到Linux服务器,并做一些MATLAB编程。我想保存隐形图为

I am SSH connecting to a Linux server and do some MATLAB programming. I would like to save invisible plot as

figH = figure('visible','off') ;
% Plot something
% save the plot as an image with same size as the plot
close(figH) ;

saveas() c> print()将更改保存图像的大小,不同于绘图的大小。还有 print(),所有三种渲染器模式( -opengl -ZBuffer -painters )不能在Linux服务器上的终端仿真模式下使用。 getframe()也不工作。
我不知道我该如何解决这些问题?

saveas() and print() will change the size of the saved image different than the size of plot. Also for print(), all three renderer modes (-opengl, -ZBuffer and -painters) can not be used in terminal emulation mode on the Linux server. getframe() doesn't work either.I wonder how I can solve these problems?Thanks and regards!

推荐答案

使用以下命令序列连接和启动MATLAB:

Use the following sequence of commands to connect and start MATLAB:

ssh -x user@server          # disabled X11 forwarding
unset DISPLAY               # unset DISPLAY variable
matlab -nodisplay           # start MATLAB without the desktop

然后一个简单的图来说明:

then a simple plot to illustrate:

figure, close                    # must do this first, otherwise plot is empty
plot(1:10)                       # usual plotting
print file                       # save the figure as file.ps
saveas(gcf, 'file.eps', 'eps2c') # saveas aslo works
exit                             # done

我只是自己尝试,并且按预期工作。

I just tried it myself, and it works as expected.

EDIT:

您可以随时使用 -r< number> 指定DPI分辨率例如非常高的分辨率:

You can always specify the DPI resolution using -r<number>, for example a very high resolution:

print -dpdf -r600 file.pdf

请注意,您可以使用 -r0 指定屏幕分辨率。

Note that you can use -r0 to specify screen resolution.

您还可以使用 PaperPositionMode 属性打开所见即所得的图形:

Also you can turn on WYSIWYG printing of figures using the PaperPositionMode property:

figure, close
plot(1:10)
set(gcf, 'PaperPositionMode', 'auto')
print -deps2c -r0 file.eps
exit

这篇关于将终端下的Matlab隐形图像保存为相同大小的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 17:37