Search code examples
matlab

Matlab running an external program finishes abruptly with this weird status code: -1.0737e+09


I can't run and external command using system or dos function in matlab, it ends with a weird status code!

‍‍system(dosCommand)

ans =

  -1.0737e+09

Solution

  • It has been answered here: https://www.mathworks.com/matlabcentral/answers/408044-what-is-the-difference-between-a-system-call-from-matlab-using-system-and-a-command-in-a-cmd-ter#answer_354381

    You need to run system('path') to see the matlab dir on path

    >> system('path');
    PATH=C:\Program Files\MATLAB\R2022b\bin\win64;; # shortened for brevity
    >>
    

    Then run your command like this:

    >> system(['set path=%path:C:\Program Files\MATLAB\R2022b\bin\win64;=% & ' dosCommand]);