2014-10-16 48 views
2

目前,我試圖做一些事情,如:Matlab的 - 積直接.ps文件

h  = figure(1); 
subplot(1, 2, 1); 
plot(X, Y); 
grid on; 
xlabel('abc'); 
ylabel('xyz'); 
title('Nice');   
legend('Awesome') 

handles  = findall(0, 'type', 'figure'); 
createPDF('outputFileName', numel(handles)); 

所以,上面會產生一個在屏幕上輸出.FIG。模塊createPDF調用將打開的圖轉換爲.ps文件並將其更改爲PDF。當我在PC上本地運行時,我看到所有數字彈出,然後轉換爲.PS並最終轉換爲PDF

但是,我正在將此作爲批處理在服務器上運行,屏幕,因此我假設也沒有.fig輸出。如何將這些圖直接發送到.PS文件。上面的代碼在for循環中運行並生成45個不同的數字。

謝謝

回答

2

打印功能是你在找什麼!

print('-dpsc2','-append','YourPSFile'); %// The '-append' is used to create a single file in the loop instead of multiple files. 

整個代碼:

clear 
clc 

for k = 1:5 

X = 1:10; 
Y = rand(1,10); 

h = figure('Visible','off'); 

plot(X, Y); 
grid on; 
xlabel('abc'); 
ylabel('xyz'); 
title('Nice');   
legend('Awesome') 

print('-dpsc2','-append','YourPSFile'); %//Simply replace 'YourPSFile'with the name you want. Easy to implement in a for-loop with sprintf for instance. 

end 

這裏是PDF格式的屏幕截圖:

enter image description here

+0

感謝Benoit_11我今日從你的代碼的東西。你可以請添加for循環的原因,我現在正在使用你的代碼創建45個PDF文件。我只想要1個PDF輸出。如果可能的話,添加您用來將PS轉換爲PDF的命令。 – Zanam 2014-10-16 15:10:58

+0

是的,我編輯了答案;您只需在要打印的電話中添加「追加」輸入,您就可以輕鬆前往。 – 2014-10-16 15:35:02

+0

您使用什麼命令將PS轉換爲PDF。我正在使用我公司創造的東西,而不是那個粉絲。 – Zanam 2014-10-16 15:37:09