How can I display the SimulationStatus in a simulink model and/or GUI?

6 ビュー (過去 30 日間)
MaSk
MaSk 2017 年 12 月 7 日
コメント済み: MaSk 2018 年 1 月 2 日
For example the user wants to see whether the simulation is running, or stopped. I know I can get_param('sys','SimulationStatus') to obtain the parameter, but how can I continuously have that updated on my simulink model or in a GUI? I know I could probably create a block mask that changes dynamically using callbacks, but I don't know the correct syntax to do so.
Thanks!

採用された回答

Kay Baumann
Kay Baumann 2017 年 12 月 31 日
Hi MaSk,
you could create a textbox:
figure()
ann = annotation('textbox',...
[0 0 0.3 0.1]);
and then write the simulation state to the textbox using the model callbacks (Model Properties >> Callbacks).
To do so, insert following code in each callback (PreLoadFcn, PostLoadFcn, ...):
ann.set('string',get_param('sys','SimulationStatus'))
Remark: using disp() to write directly to the Command Window instead of a textbox seems not to work anymore (tried it with MATLAB 2016b).
  1 件のコメント
MaSk
MaSk 2018 年 1 月 2 日
Thank you, this works well! What I ended up solving my problem with was within the mask display window executing the following:
y = get_param('sys','SimulationStatus');
if strcmp(y, 'stopped')
image('SimStopped.jpg')
elseif strcmp(y,'running')
image('SimRunning.jpg')
else strcmp(y,'paused')
disp('paused')
end
I just created images that represented what I wanted to display in the box.
Thanks for the help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeModel, Block, and Port Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by