How to print messages in Simulink diagnostic viewer when Sim command is used
13 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
Dhruv
2023-9-21
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Configure and View Diagnostics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!