Run Python outside of Matlab

I am developing a Matlab interface for a Python program that accepts command line inputs. I want to use Matlab to prepare the inputs and call the program. When I feed the inputs to system() or dos(), the program appears to start (some of the output in in the command window is correct) but it doesn't run. If I use those same inputs in a terminal (cmd.exe) then the program runs as intended. I don't need the program to run inside of Matlab, the outputs are going to several different files that I can load later. Is it possible to use Matlab to call a program to run external to Matlab?

 Accepted Answer

In such cases I tend to write .bat files and start them:
system(['start "" "' fn '"']);
%The first "" is required, because otherwise the file name is treated as
%the window title.

2 Comments

Thanks for the answer, that worked! It is unfortunate that I was unable to run it inside the command window. It would have been convenient to let Matlab know when the batch file was done. I will make do with using input() and having the user indicate the end before I start post-processing.
You're welcome.
You could also try without the start to make the system call hang until the execution of the .bat completes. Depending on the root cause of the issue you were having, that might also work.

Sign in to comment.

More Answers (0)

Products

Release

R2017b

Asked:

on 8 Jun 2021

Commented:

Rik
on 8 Jun 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!