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

6 visualizaciones (últimos 30 días)
Ender
Ender el 9 de Feb. de 2016
Comentada: Jonathan el 6 de Jul. de 2020
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 comentario
Jonathan
Jonathan el 6 de Jul. de 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".

Iniciar sesión para comentar.

Respuestas (2)

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

Sebastian
Sebastian el 18 de Oct. de 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.

Categorías

Más información sobre Configure and View Diagnostics en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by