在MATLAB中调用系统命令 [英] call system command within MATLAB
本文介绍了在MATLAB中调用系统命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在调用exe命令:
I'm calling an exe command :
myCmd = fullfile('working',myCommand.bat');
[status,message] = system(myCmd )
status = 0
message =
processing value ...
complete
activating command ...
complete
如何从消息中获取一些文字? 例如,我想获取第一个文本"和完成"以检查第一个操作是否完成?
How could I get some text from message ? For example i would like to get the "first text" and "complete" to check the first action is completed ?
谢谢
推荐答案
使用echo
命令包含返回消息:
Use the echo
command to include a return message:
[status,message] = system('yourCommand && echo hello world' )
将返回:
message =
hello world
通常,您将需要创建一个字符串,在其中级联与&&
连接的所有命令.然后,其中一个命令可以是echo something
.
Generally you will need to create a string where you cascade all your commands connected with &&
. One of the commands could then be echo something
.
关于您的
output = 'processing value ...'
command = ['cd ' myCMD ' && myCommand.bat' ' && echo ' output];
[status,message] = system( command )
将调用myCommand.bat
并返回处理值...".
will call myCommand.bat
and return "processing value...".
这篇关于在MATLAB中调用系统命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文