MATLAB: How do i see the printed lines of a .exe file in Matlab

cmdexeexe with parametersMATLABMATLAB and Simulink Student Suitewindows

Hello, i have the following problem: i wrote an test.exe, that i want to start from matlab with the parameter 3. So i use:
system('test.exe 3')
The test.exe has the following code: …
printf('The parameter was %d!, is it right(y/n)=?',number);
a=getchar();...
So when i start the test.exe from the windows cmd, it will first show me the text and waits for the char.
When i start the test.exe, it will show the text after the char was handed char over.
How can I solve this problem? Is it possible to start the windows cmd from matlab, so i can see the printed lines in the windows cmd window?
Thank you for Help and sorry for the bad english!

Best Answer

This isn't something MATLAB can do with system calls. And it makes sense that way, because the entire point of system or ! is that you want MATLAB to run those commands for you in the background.
To accomplish your goal, you need a command that tells Windows to force something to the foreground:
system('start test.exe 3');
Beware that with the "start" directive, the operating environment (i.e., working directory, etc.) get a lot more convoluted. Further, this will still probably be useless to you, because I'm pretty sure MATLAB continues as soon as the call is made. It won't wait for the spawned command window to be closed, so you can't use anything with whatever it is that text.exe does.