필터 지우기
필터 지우기

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

조회 수: 10 (최근 30일)
Ender
Ender 2016년 2월 9일
댓글: Jonathan 2020년 7월 6일
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
Jonathan
Jonathan 2020년 7월 6일
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".

댓글을 달려면 로그인하십시오.

답변 (2개)

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

Sebastian
Sebastian 2016년 10월 18일
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.

카테고리

Help CenterFile Exchange에서 Configure and View Diagnostics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by