问题描述
好的,我已经搜索了整个网站,但没有任何运气.
Okay, I've searched all across this site, without any luck.
这是我的问题:
我有一个 .exe,它在运行时生成两个输出文件,当我实际使用 .exe 本身时它运行良好.
I have an .exe that produces two output files when run, which it does fine when I actually use the .exe itself.
但是,当我在 MATLAB 中运行它时(是的,它实际上运行并具有相同的系统消息,就像在命令提示符中一样),不会生成两个输出文件.我不确定这是否可以在 MATLAB 中使用 system() 进行控制,或者这是 .exe 的问题.
However, when I run it in MATLAB (yes it actually runs and has identical system messages just like in the command prompt), the two output files are NOT produced. I'm not sure if this is something that can be controlled using system() in MATLAB, or this is a problem with the .exe.
我运行 .exe 的代码(它还需要一个输入文件)是这样的:
My code to run the .exe (it also takes an input file) is simply this:
system(['C:\MyProgram.exe ' myInputFile]);
非常感谢任何提示、指示、建议或解决方案!!!
Any tips, pointers, advice, or solutions are greatly appreciated!!!
推荐答案
我假设 myInputfile
是一个字符串.我猜你的程序没有运行,因为我会说你的命令不起作用.请尝试以下操作:
I assume myInputfile
as a string. I guess your program is NOT running, because I'd say your command is not working. Try the following:
yourCommand = strcat('c: && MyProgram.exe',{' '},myInputFile);
system( yourCommand{1} );
{' '}
是必要的,因为字符串末尾的空格会被忽略.你不能只在命令行中输入你的路径,你需要在之前定义路径然后调用函数.由于不能将所有命令排成一行,因此需要使用 &&
,就像在命令窗口中键入 Enter
一样.
{' '}
is neccesary, because spaces at the end of strings are ignored.You can not just type your path into the command line, you need to define the path before and then call the function. As you cannot put all commands in a row, you need to use &&
, which is like typing Enter
in the command window.
这篇关于在 matlab 中运行的 .exe 不会像在命令提示符中运行时那样创建两个输出文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!