从 MATLAB 调用 Powershell 不会移动到 MATLAB 中的下一行
Calling Powershell from MATLAB does not move to next line in MATLAB
我有一个使用 !powershell 调用 powershell 的命令。它工作正常,但是,第一个命令将从外部程序执行数据发布操作,并且在有发布数据的订阅者之前不会继续执行 MATLAB 中的下一行代码。问题是下一行代码是订阅已发布数据的代码,因此它只是 运行s 永远等待数据。任何想法如何使代码继续?我已经尝试了 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);
您需要在后台启动作业,以便 PowerShell returns 在作业完成之前立即启动。请注意,等待作业完成的是 PowerShell,而不是 MATLAB。
在后台使用与号 (&
) 结束 PowerShell 命令以 运行 它:
[status_one,publish] = system('powershell -inputformat none cd path &');
我有一个使用 !powershell 调用 powershell 的命令。它工作正常,但是,第一个命令将从外部程序执行数据发布操作,并且在有发布数据的订阅者之前不会继续执行 MATLAB 中的下一行代码。问题是下一行代码是订阅已发布数据的代码,因此它只是 运行s 永远等待数据。任何想法如何使代码继续?我已经尝试了 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);
您需要在后台启动作业,以便 PowerShell returns 在作业完成之前立即启动。请注意,等待作业完成的是 PowerShell,而不是 MATLAB。
在后台使用与号 (&
) 结束 PowerShell 命令以 运行 它:
[status_one,publish] = system('powershell -inputformat none cd path &');