coder.ceval('printf',....) does not print a message instantaneously
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi! I need to print a message every few iterations during a simulation to control current state of the simulation. Since the m-file is designated for C-code generation using codegen, I use coder.ceval('printf',...) method. When I verify the compiled C-code using .mex function, none of the messages is printed during the simulation. Instead, all messages are printed at once after the simulation finishes. How can I force codegen to print a message instanteneously? Does anything similar to drawnow exist for coder.ceval('printf',..)? Anyone's help is appreciated!
0 Kommentare
Akzeptierte Antwort
Friedrich
am 17 Aug. 2012
Bearbeitet: Friedrich
am 17 Aug. 2012
Hi,
as long you stay with mex you can do a
mexEvalString("drawnow");
So a
coder.ceval('mexEvalString', '"drawnow"')
This will give the MATLAB Thread enough time to flush the buffer and to display the data.
In the case you want to generate code not for mex only you can use the coder.target to differentiate between those cases during the code generation process:
if strcmp('mex',coder.target)
coder.ceval('mexEvalString', '"drawnow"')
end
1 Kommentar
Weitere Antworten (1)
Tomas Jurena
am 20 Aug. 2012
Bearbeitet: Tomas Jurena
am 20 Aug. 2012
1 Kommentar
Juan Rojas
am 20 Feb. 2013
how do you create the C_formatted_message?
In my case I use printf with a file stream as: coder.ceval('printf',fid,s11,s12,int32(i));
Where fid was declared as: fid = coder.opaque('FILE *','NULL');
Siehe auch
Kategorien
Mehr zu Generating Code finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!