I have a MATLAB script that calls an executable (written in C++) using the system()
command, like so:
exe_status = system('MySimulation.exe', arguments);
Since the executable can take quite a long time to run (up to several hours), I including a function within it that estimates the time remaining and outputs that to the console. If I run the executable outside of MATLAB, the Windows console looks roughly like this:
Simulation #B01 initiated...
Completion: 0.57% Time remaining: 183 m 2 s
Using the \r
character, the "completion" line rewrites itself every second. This works really well, and lets me know when to come back to analyze the data.
Unfortunately, calling the executable from the MATLAB console does not have the same effect. MATLAB waits until the executable has terminated before showing any console output at all, rendering my timer moot.
I've tried the following commands, but they all have the same behavior:
exe_status = system('MySimulation.exe', arguments);
exe_status = system('MySimulation.exe', arguments, '-echo');
exe_status = dos('MySimulation.exe', arguments);
exe_status = dos('MySimulation.exe', arguments, '-echo');
Unless I'm reading incorrectly, it seems that the MATLAB documentation suggests that '-echo'
can be used to echo the command output while the executable is still running, but it has no effect on my particular program.