0
時候當我打電話MATLAB從PowerShell中,它工作正常:返回值調用Matlab
$command = "path-to-matlab.exe"
$args = "-nosplash -nodesktop -r run('path-to-my-mfile.m');exit();"
$process = Start-Process -Wait -PassThru $command $args
write-output $process.ExitCode
然而,當有一個在MATLAB的錯誤,怎麼能PowerShell的知道嗎?
我試過了從MATLAB的exit(1)
,但變量$process.ExitCode
仍然返回0
。
我也試過從MATLAB內部fprintf('some error message')
,但它不打印到PowerShell控制檯,但只打印在MATLAB窗口。