Run Python outside of Matlab

4 次查看(过去 30 天)
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?

采纳的回答

Rik
Rik 2021-6-8
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 个评论
Michael Bair
Michael Bair 2021-6-8
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.
Rik
Rik 2021-6-8
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Python Package Integration 的更多信息

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by