Azzera filtri
Azzera filtri

Redirecting stdout via system(…,'-echo')

30 visualizzazioni (ultimi 30 giorni)
Darren Engwirda
Darren Engwirda il 14 Dic 2016
Commentato: David Wyatt il 25 Set 2018
I often call computationally intensive command-line programs from within MATLAB using the system command:
[status, result] = system(cmd_line_for_my_low_level_exe, '-echo');
where the -echo option (supposedly) echoes console output (stdout) generated by low_level_exe in the MATLAB command window.
On Linux machines this works great, with MATLAB echoing the console output in (seemingly) real-time. Users get a nice continuous update on low_level_exe's progress.
On Windows machines this is not the case. It can often be many minutes in-between echoes, and users sometimes get impatient and assume the code has crashed...
Is there a way to increase/control the frequency of MATLAB's -echo, or possibly another, better alternative entirely? (I'd prefer to stay away from mex files to maintain compatibility with Octave).
Is this actually a MATLAB issue, or just a Linux/Windows incompatibility?

Risposte (1)

Jose Lara
Jose Lara il 16 Dic 2016
Modificato: Jose Lara il 16 Dic 2016
Darren, One thing to try to not use the second output argument, but write the output of the operating system command to a file. For example,
>> s = system(['echo ' cmd_line_for_my_low_level_exe ' >> out.txt']);
And read the file back into MATLAB:
>> r = textscan('out.txt');
It does add an extra line to your script but will be computed faster.
  1 Commento
David Wyatt
David Wyatt il 25 Set 2018
I have the same problem as the OP.
However, I'm not clear on how to use textscan to show the output from the operating system command in "real time", since it is not (as far as I am aware) possible to easily loop while the system command is running, or to detect when the command has finished in another thread.
Please could you elaborate?
Many thanks in advance.

Accedi per commentare.

Categorie

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

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by