Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab-直接打印到.ps文件_Matlab - Fatal编程技术网

Matlab-直接打印到.ps文件

Matlab-直接打印到.ps文件,matlab,Matlab,目前,我正在尝试做以下工作: 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( hand

目前,我正在尝试做以下工作:

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。当我在我的电脑上本地运行这个程序时,我看到所有的数字都会弹出,然后转换成.PS,最终转换成PDF

但是,我正在以批处理的方式在服务器上运行它,没有屏幕,因此我假设也不会有.fig输出。如何将这些绘图直接发送到.PS文件。上面的代码在for循环中运行,并生成45个不同的图形


谢谢

您正在寻找打印功能

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的屏幕截图:


谢谢Benoit_11我今天从您的代码中学到了一些东西。你能添加一个for循环吗?因为现在我正在用你的代码创建45个PDF。我只需要1个PDF输出。如果可能的话,添加你用来将PS转换成PDF的命令。是的,我编辑了答案;您只需在打印调用中添加“append”输入即可。您使用什么命令将PS转换为PDF。我用的是我的公司创造的东西,我不太喜欢。哦,我用Acrobat打开了ps文件,它工作得很好。对于Matlab脚本,您可以通过文件交换查看此提交:谢谢Benoit_11。我会让你知道它是否适用于我的夜间进程设置,我相信这是一个服务器,运行一些版本的Linux。