在Matlab中执行系统命令而无需等待 [英] executing system command in Matlab without waiting

查看:207
本文介绍了在Matlab中执行系统命令而无需等待的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用一个Matlab GUI操作三台仪器.

I am trying to operate three instruments using one Matlab GUI.

  • 一台仪器只需通过串行端口发送数据.
  • 第二个已配置并开始通过虚拟串行端口发送数据,但使用的是制造商的SDK(我正在使用Matlab的修改后示例脚本与仪器通信)
  • 第三种方法使用编译的C ++程序,该程序执行时会配置仪器并开始发送数据,但将其保存在Matlab之外.与其他传感器不同,该仪器仅需几秒钟即可运行:

  • One instrument simply sends data via serial port.
  • Second is configurated and starts sending data via virtual serial port but using manufacturer's SDK (I am using modified example script for Matlab to comunicate with instrument)
  • Third uses compiled C++ program which execution configures instrument and starts sending data but saves it outside Matlab. This instrument operates just few second unlike other sensors:

system('ctrllib_demo3.exe 192.168.0.125 C:\ ScanPos003.rxp 30,130,1,0,360,1 1')

system('ctrllib_demo3.exe 192.168.0.125 C:\ScanPos003.rxp 30,130,1,0,360,1 1')

独立运行每台仪器时,工作正常.同样第一和第二作品都很好.但是,当上述命令运行时,第二台仪器将停止发送数据,而第一台仪器将继续发送数据.每个传感器具有不同的功能.

While running each instrument independently, works fine. Also first together with second works fine. But while above command runs, second instrument stops sending data while first continues. Each sensor is operated from different function.

可能由于以下原因引起:该操作等待命令完成执行,然后将命令的退出状态返回到状态变量." ( mathworks/system )? 在那种情况下,为什么第一台仪器仍在运行?

Could it be caused due to: "The operation waits for the command to finish execution before returning the exit status of the command to the status variable." (mathworks/system)? In that case why the first instrument is still running?

推荐答案

您可以在后台模式下运行外部命令,方法是将&附加到操作系统命令!上,例如:

You can run an external command in background mode by appending & to the operating system command ! for example:

!notepad.exe test.txt &

将在记事本中打开test.txt并立即将控制权返回到命令窗口.

will open test.txt in notepad and return control to the command window immmediately.

运行外部命令,脚本和程序

这篇关于在Matlab中执行系统命令而无需等待的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆