Displaying progress from a file compiled to MEX with MATLAB Coder.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a slow running .m file that I am compiling to MEX via MATLAB Coder.
I would like to display the loop counter in the code's main loop.
However, with an fprintf, nothing is getting printed until the function exits.
I have tried the following, but even this does not fix the problem completely:
if ~coder.target( 'MATLAB' )
coder.cinclude( 'fflushStdOut.h' );
end
...
fprintf( '%d\n', NSample );
if ~coder.target( 'MATLAB' )
coder.ceval( 'fflushStdOut', int32( 0 ) );
end
drawnow update;
Where fflushStdOut.h contains:
#ifndef FFLUSH_STD_OUT_H
#define FFLUSH_STD_OUT_H
#define fflushStdOut( x ) fflush( stdout );
#endif
Even with this, the function is still not displaying anything until 1800+ iterations have past, which takes a good 30 minutes.
Any ideas?
0 commentaires
Réponses (1)
Denis Gurchenkov
le 25 Oct 2016
A combination of 'drawnow' and 'mexPrintf' seem to work:
function test1
coder.extrinsic('drawnow');
for i = 1:1000
coder.ceval('mexPrintf', ['hello' 10 0]);
drawnow();
coder.ceval('Sleep', int32(100));
end
end
codegen test1 -config:mex
test1_mex
Prints 'hello' every 0.1 seconds
0 commentaires
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!