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일

0 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

제품

릴리스

R2017b

질문:

2021년 6월 8일

댓글:

Rik
2021년 6월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by