【问题标题】:Calling Powershell from MATLAB does not move to next line in MATLAB从 MATLAB 调用 Powershell 不会移动到 MATLAB 中的下一行
【发布时间】:2020-06-01 12:14:44
【问题描述】:

我有一个使用 !powershell 调用 powershell 的命令。它工作正常,但是,第一个命令将执行来自外部程序的数据发布操作,并且在有发布数据的订阅者之前不会继续执行 MATLAB 中的下一行代码。问题是下一行代码是订阅已发布数据的代码,因此它只会一直运行以等待数据。任何想法如何使代码继续?我已经尝试过 continue 语句,但由于我调用了 powershell,它一直存在并且 MATLAB 命令不会被执行。另外,我试图向后运行命令,所以订阅者首先和发布者之后,但遇到同样的问题。有任何想法吗?

pubPath = 'powershell -inputformat none cd path' ;
subPath = 'powershell -inputformat none cd path2';

[status_one,publish] = system(pubPath);
[status_two,subscribe] = system(subPath);

【问题讨论】:

    标签: matlab powershell command command-prompt


    【解决方案1】:

    您需要在后台启动作业,以便 PowerShell 在作业完成之前立即返回。请注意,等待作业完成的是 PowerShell,而不是 MATLAB。

    以 & 符号 (&) 结束 PowerShell 命令以在后台运行它:

    [status_one,publish] = system('powershell -inputformat none cd path &');
    

    【讨论】:

      猜你喜欢
      • 2017-11-06
      • 1970-01-01
      • 1970-01-01
      • 2016-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多