如何在gnuplot中运行系统命令

如何在gnuplot中运行系统命令,gnuplot,Gnuplot,我想让gnuplot脚本输出*.eps文件,并将它们自动更改为.pdf类型。我有一个测试演示,如下所示: set term postscript eps enhanced color set output "SystemCommand.eps" plot sin(x) set xl "x" set yl "y=sin(x)" system(sprintf("epstopdf %s",SystemCommand.eps)) 但它不能产生我想要的,每次都会出现一个错误,它说: "Syste

我想让gnuplot脚本输出*.eps文件,并将它们自动更改为.pdf类型。我有一个测试演示,如下所示:

set term postscript eps enhanced color
set output "SystemCommand.eps"

plot sin(x)

set xl "x"

set yl "y=sin(x)"

system(sprintf("epstopdf %s",SystemCommand.eps))
但它不能产生我想要的,每次都会出现一个错误,它说:

"SystemCommand.gp", line 6: undefined variable: SystemCommand
我尝试过使用SystemCommand或SystemCommand.eps,这里没有区别。有人有什么建议吗?
我使用Ubuntu 14.04和bash shell。

您需要在
sprintf
中引用文件名

set term postscript eps enhanced color
set output "SystemCommand.eps"

plot sin(x)

set xl "x"

set yl "y=sin(x)"

system(sprintf("epstopdf %s","SystemCommand.eps"))

非常感谢。这确实有效。此外,我还发现添加了[链接]!打印脚本的epstopdf SystemCommand.eps'也会生成一个pdf文件。我不知道有什么不同,但我只是提供了另一个选择。很高兴它有帮助!如果我的答案解决了你的问题,你可以点击左边的复选标记来接受。是的,我知道。但我是新来的,它说我没有足够的声誉!命令与系统(命令)相同。此外,不需要sprintf,因为您只需连接两个字符串:
system(“epstopdf”。“SystemCommand.eps”)