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?

 Akzeptierte Antwort

Rik
Rik am 8 Jun. 2021

0 Stimmen

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 Kommentare

Michael Bair
Michael Bair am 8 Jun. 2021
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 am 8 Jun. 2021
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Produkte

Version

R2017b

Gefragt:

am 8 Jun. 2021

Kommentiert:

Rik
am 8 Jun. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by