View progress of simulation when using sim command

67 ビュー (過去 30 日間)
Mazin
Mazin 2015 年 1 月 5 日
回答済み: Brian Ventura 2024 年 4 月 19 日
I am running a simulink model through matlab code using the sim() command. Normally when you run a simulink model you see a nice progress bar on the bottom right, showing you how far the compilation and then at which simulation time step it is. But this is not visible when I use the sim() command. Is there someway to get this information (mainly at which simulation time it is at the moment would be nice to know)?
Thanks!

採用された回答

A Jenkins
A Jenkins 2015 年 1 月 5 日
Perhaps try the Simulink Waitbar example on the File Exchange?
  2 件のコメント
Mazin
Mazin 2015 年 1 月 7 日
Thanks! I have searched the FileExchange for one that shows the time in numbers instead of just a progress bar, but haven't been able to find one. Do you know if that exists? But I guess this is also good enough :)
A Jenkins
A Jenkins 2015 年 1 月 7 日
You can just print the number on the waitbar.
1) Go into the Embedded MATLAB function and change the waitbar call to include the message:
function y = fcn(u1, u2, h)
% This block supports an embeddable subset of the MATLAB language.
% See the help menu for details.
coder.extrinsic('waitbar')
coder.extrinsic('sprintf')
waitbar(u1/u2,h,sprintf('Time = %.f/%.f', u1, u2))
y = 1;
2) You will also need to pass the handle to the waitbar in. You can do this by choosing "Edit data" from the editor, (or opening the model explorer and navigating to the Embedded MATLAB Function), then selecting the handle "h", and changing the Scope to Parameter.

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

その他の回答 (2 件)

Ramon
Ramon 2017 年 1 月 18 日
My simulink compiler says that code cannot be generated for matlab function waitbar.

Brian Ventura
Brian Ventura 2024 年 4 月 19 日
Perhaps try the following command instead of sim(modelname)
>> set_param(modelname,'SimulationCommand','start');

カテゴリ

Help Center および File ExchangeDialog Boxes についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by