【发布时间】:2012-07-10 13:17:52
【问题描述】:
我有一个可执行文件,它在运行时询问参数文件的名称。我尝试了所有输入参数文件名称的方式,但我得到了同样的错误:
GAM Version: 2.905
ERROR - the parameter file does not exist,
check for the file and try again
Stop - Program terminated.
ans =
0
参数文件的名称是gam.par。我为函数自动读取参数文件名称尝试的各种样式是:
system('"gam.exe" -f "gam.par"')
system('"gam.exe" -f "gam.par"')
system('"gam.exe" -f gam.par')
system('gam.exe -f gam.par')
system('"gam.exe" /f gam.par')
system('"gam.exe" /f gam.par /o gam.out')
system('"C:\Users\...\gam.exe" /f gam.par /o gam.out')
system(['"C:\Users\...\gam.exe" /f gam.par /o gam.out'])
其中gam.par 和gam.par 分别是参数(输入)文件和输出文件。但是,在上述每种情况下,我都会收到与开头所示相同的错误消息。
我所有的文件(输入、输出、可执行文件等)都在同一个文件夹中。如果我使用 system() 函数而不使用参数文件的名称,那么它会正常运行并提示我输入参数文件名,当我在提示符下输入相同的文件名(即gam.par)时,一切正常。我希望能够通过在 system() 参数中输入参数文件名来自动执行此操作,而不是在提示时手动输入。如果有人能确定我为什么无法得到我想要做的事情,那将会很有帮助。谢谢!
【问题讨论】:
-
你试过
system('gam.exe gam.par')吗?我在文档中没有看到 -f 标志/选项。 -
酷!有效 :)。我使用了 -f 标志/选项,因为我之前曾为不同的软件使用过 system() 函数,因此我不得不在那里使用 -f。你可以把它放在答案中,我可以接受。非常感谢。
标签: matlab arguments system parameter-passing executable