I am trying to write a MATLAB script that would call and run an external program and then proceed with other MATLAB commands.
tic %Start stopwatch
system('MyProgram.exe') %Call and run my program
toc %End stopwatch
However, this program "MyProgram.exe" requires me to "Press Enter to Exit." How to make my MATLAB script pass "Enter" to proceed? Like How to pass "Enter" as an input of my program at the end of execution? Or how to do this in general ?
On UNIX, you can use
as suggested in the Matlab documentation:
The Windows equivalent is (based on this post):
When a console program needs to take input one time from the user and there is no built-in way to do so (like passing it in as an argument), that input can be
echo
ed and piped to the program. This can also be used to press Enter (again, once) by piping a blank line.While traditionally a blank line is generated with
echo
by using the commandecho.
, this can fail if the current directory contains a file called echo that has no extension. To get around this, you can use a(
instead of a.
.