When I call MATLAB from PowerShell, it works fine:
$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
(Similar to this question here)
However, when there's an error in MATLAB, how can PowerShell know?
I tried exit(1)
from MATLAB, but the variable $process.ExitCode
still returns 0
.
I also tried fprintf('some error message')
from within MATLAB, but it doesn't get printed to the PowerShell console, but only printed in MATLAB window.