How to print messages in Simulink diagnostic viewer when Sim command is used

15 visualizzazioni (ultimi 30 giorni)
I have an s-function block. It prints some messages during Simulation and compilation. I am using mexprintf to print this messages.
When I use 'sim' command, this messages are getting printed in the MATLAB Command window. But I want this messages in the Simulink Diagnostic viewer.
How to achieve this?

Risposte (1)

Dhruv
Dhruv il 21 Set 2023
I understand that you want to use the 'sim' command to print messages via an S-Function block. Currently, the messages appear in the MATLAB Command Window, but you'd like them to be in the Simulink Diagnostic Viewer.
The approach to achieve this depends on your specific workflow. Typically, the 'sim' command is used for entirely programmatic workflows where the model isn't even opened, instead just loaded.
If your goal is to programmatically initiate the simulation to mimic clicking the play button in Simulink's GUI and have the messages appear in the Diagnostic Viewer, you can use the following MATLAB command:
>> set_param('<model_name>', 'SimulationCommand', 'start');
Replace <model_name> with the name of your Simulink model. This command will initiate the simulation as if you had run the model from the Simulink GUI, and any messages generated by the S-Function block will be directed to the Simulink Diagnostic Viewer.

Categorie

Scopri di più su Configure and View Diagnostics in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by