Azzera filtri
Azzera filtri

Running .exe file from MTLAB using system() and Wait until the program closes

5 visualizzazioni (ultimi 30 giorni)
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

Risposte (2)

dpb
dpb il 25 Set 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...
  1 Commento
abbas jalilian
abbas jalilian il 17 Ott 2017
Thank you for your answer But my problem has not yet been resolved I've written a program with Processing and when I run it, MATLAB instantly runs the next lines.

Accedi per commentare.


Joao
Joao il 28 Set 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 Commenti
Steven Lord
Steven Lord il 28 Set 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
dpb il 28 Set 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.
>>

Accedi per commentare.

Categorie

Scopri di più su Programming in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by