How to redirect Simulink diagnostic viewer output to MATLAB command line?

5 views (last 30 days)
I used to use the diary function in conjunction with the disp function quite a bit to do debugging of my code that involved both MATLAB and Simulink models. MATLAB code could also be a part of the Simulink models themselves (block callback functions, S-Functions, etc.) as well as being part of various driver programs. I know that there are other more sophisticated ways of debugging but good-old "printf" is a tried and tested way of debugging in many languages.
Calls to disp in Simulink-related code have been directed to the Simulink diagnostic viewer in recent releases. This has resulted in a disconnection between the MATLAB-only parts of my applications and the Simulink parts. I would like to see all of the calls to disp placed together.
Simply: is there any way to redirect the output of the Simulink Diagnostics Viewer to the MATLAB command line?
Thanks.
  1 Comment
Jonathan
Jonathan on 6 Jul 2020
I have the same concern with R2016b. It seems a very basic question on the use of Simulink models. I can't see how there isn't a simple answer such as "yes it's possible, here's how to configure..." or "no that's not possible".

Sign in to comment.

Answers (2)

Lauri B
Lauri B on 29 Jan 2018
If you run your simulation from the Matlab command line you should also get diagnostic viewer output there:
>> simOut = sim('MyModel');

Sebastian
Sebastian on 18 Oct 2016
Unfortunately I am also on the search for redirecting the diagnostic viewer output to the Matlab Command Window, and have not yet found a solution for it. But you can log the output to a file, using the Diagnostic Viewer's "diary" function. It is as simple as that:
sldiagviewer.diary('my-log-file.txt') % Start logging to file
% Do any model actions here, also manually
set_param(bdroot, 'SimulationCommand', 'Update');
sldiagviewer.diary('off') % Stop logging
The parameters to "sldiagviewer.diary" are the same as its Matlab counterpart.

Categories

Find more on Configure and View Diagnostics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!