Running .exe file from MTLAB using system() and Wait until the program closes
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi everyone,
I use system to run my executable file:
system('myfile.exe')
How to determine that the program was closed? I want MATLAB to run the next line after closing the execution program. Thanks
0 Kommentare
Antworten (2)
dpb
am 25 Sep. 2017
>> help system
system Execute system command and return result.
[status,result] = system('command') calls upon the operating system to
execute the given command. The resulting status and standard output
are returned.
...
continue reading for further details...
Joao
am 28 Sep. 2017
I have a similar issue, but in my case the variables status / result are not updated when the executable finishes. It seems to me that these variables are in place to indicate the status of the call to the system function not its output! Any further ideas would be much appreciated!
2 Kommentare
Steven Lord
am 28 Sep. 2017
You should probably post this as a separate question, not as an answer on another question. If you do post as a separate question please show the exact line of code you use to call your executable, state what you observed when you executed that line of code, and explain what you expected that line of code to do (referencing parts of that code).
dpb
am 28 Sep. 2017
The status is command status; whether it was/was not executed w/o error. The result returned is dependent upon the executed command using stdout for whatever output it returns. Also if you use the trailing ampersand '&' when submitting the command the result output is not updated and status is the status on launching the background session, not on completion.
It can be illustrated to work with command that is known to behave using stdin/stdout; not every console program you may try to execute follows those rules--
>> [stat,res]=system('cd') % simple command w/ known output...
stat =
0
res =
C:\ML_R2014b\work
>> [stat,res]=system('cd:') % oopsies, made a typo...
stat =
1
res =
The filename, directory name, or volume label syntax is incorrect.
>>
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!