2009-12-05 21 views
15

我是SSH連接到Linux服務器並執行一些MATLAB編程。我想無形的情節保存爲將Matlab在終端下的不可見圖像保存爲相同大小的圖像

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

saveas()print()將更改保存的圖像比圖的大小不同的大小。同樣對於print(),在Linux服務器上,所有三種渲染器模式(-opengl,-ZBuffer-painters)都不能在終端仿真模式下使用。 getframe()也不起作用。 我不知道如何解決這些問題? 謝謝,問候!

+0

你運行你的一個X服務器? – Amro 2009-12-05 20:07:12

+0

服務器沒有X. – Tim 2009-12-05 20:11:04

回答

15

使用下面的命令序列連接和啓動MATLAB:

ssh -x [email protected]   # disabled X11 forwarding 
unset DISPLAY    # unset DISPLAY variable 
matlab -nodisplay   # start MATLAB without the desktop 

然後進行簡單的情節來說明:

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 

我剛剛試了一下自己,它將按預期工作。


編輯:

你總是可以指定使用-r<number>的DPI分辨率,例如一個非常高的分辨率:

print -dpdf -r600 file.pdf 

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

你也可以打開的使用PaperPositionMode財產數字所見即所得打印:

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

問題在於使用saveas()或print()不會保存與繪圖相同的已保存圖像大小。 – Tim 2009-12-05 20:56:32

+0

是不是已經解決您的上一個問題:http://stackoverflow.com/questions/1848176/how-not-to-save-non-image-area-in-matlab-image-plot – Amro 2009-12-05 21:02:39

+0

解決方案前提是實際上不用於終端模式和Matlab不可見的繪圖(我只是基於它可以在X模式和Matlab可見繪圖上工作而接受它)。即使在你建議連接到服務器並運行Matlab的方式下,getframe()也會返回null。 – Tim 2009-12-05 21:13:59

相關問題