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

9 ビュー (過去 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 Center および File ExchangeConfigure and View Diagnostics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by