当从 Matlab 运行 .exe 文件时,如何避免手动输入输入文件?
我正在使用 trans.exe
文件,该文件在运行时要求提供参数(=输入)文件。如果我使用Matlab运行trans.exe
,那么如何在每次trans.exe
运行时Matlab提示手动输入的情况下,直接在程序内部给出参数文件?跑步?
I am using a trans.exe
file, which when run asks for a parameter (=input) file. If I run trans.exe
using Matlab, then how can I directly give the parameter file inside the program without being prompted by Matlab to type it manually each time trans.exe
is run?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的可执行文件无法接受命令行参数,那么您唯一的选择是调用一个调用,将内容通过管道传输到可执行文件的标准输入(在 Linux 下,这将类似于
!echo "blah等等等等”| my_executable
)。不过,我不知道该技术在 Matlab 中是否有效。If your executable doesn't have the ability to accept command-line parameters, then your only option is to invoke a call which pipes stuff to the stdin of your executable (under Linux, this would be something like
!echo "blah blah blah" | my_executable
). I don't know if this technique works from Matlab, though.system('"C:\path_name\trans.exe" < "C:\path_name\input_trans_parameter_file.txt"');
上面
system
中使用的命令行如下函数直接使用input_trans_parameter_file.txt
中存储的输入文件的名称。<强>< “C:\path_name\input_trans_parameter_file.txt”
system('"C:\path_name\trans.exe" < "C:\path_name\input_trans_parameter_file.txt"');
The following command line used in above
system
function directly uses the name of the input file stored ininput_trans_parameter_file.txt
.< "C:\path_name\input_trans_parameter_file.txt"