MATLAB System Command "Press Enter to Exit"

I am trying to write a MATLAB script that will call and run an external program, and then continue 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 do I make my MATLAB script pass "Enter" a continuation? How do I pass "Enter" as input to my program at the end of execution? Or how to do it at all?

+3


source to share


2 answers


On UNIX, you can use

system('MyProgram < /dev/null'). 

      

as stated in Matlab documentation :



To disable stdin and type-forward redirection, include formatted text < /dev/null

in the invocation of the command being invoked.

Windows equivalent (based on this post ):

system('MyProgram.exe < NUL')

      

+4


source


When a console program needs to take one time from the user, and there is no built-in way to do this (like passing it as an argument), that input can be echo

ed and passed to the program.This can also be used to press Enter (again, once) by shim empty line.

echo.|program.exe

      



While the traditional empty string is generated by using echo

a command echo.

, this can fail if the current directory contains a file named echo that has no extension. To get around this, you can use (

instead .

.

echo(|program.exe

      

+4


source







All Articles