Simulink model prints callback messages to the Diagnostic Viewer, how do I print to the Command Window?
Afficher commentaires plus anciens
I am using a Simulink model PostLoadFcn to run a MATLAB function when the model is opened.
The callback invokes:
PostLoadFcnTest();
When the model is opened (either via double‑clicking the .slx file or using open_system(modelname)), none of the usual printing mechanisms work.
Instead, all output appears in the Diagnostic Viewer.
Here is my callback setup:


Every attempt to print to the Command Window is redirected to Diagnostic Viewer:
- disp()
- fprintf()
- fprintf(1, ...)
- evalin('base', ...)
- warning()
- Simulink.output.info()
- even onCleanup()

However, if I defer printing using a MATLAB timer, the message does appear in the Command Window:

My Questions
- Is it expected behavior that PostLoadFcn suppresses stdout and forces all output into Diagnostic Viewer?
- Is there any official MATLAB/Simulink supported way to print to the Command Window directly from PostLoadFcn without requiring changes to Diagnostic Viewer configuration?(Besides the timer workaround.)
- Is there a recommended callback alternative to PostLoadFcn that runs after model is opened AND allows normal stdout printing?
- Is stdout intentionally locked during model load/update? If yes, is this documented anywhere?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Model, Block, and Port Callbacks dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!