Simulink Block vs Simulink Model

Dear MATLAB Community,
Can someone please explain the difference between a Simulink Model and a Simulink Block? I'm trying to understand why there is an InitFcn callback for both (https://www.mathworks.com/help/simulink/ug/initialization-function.html?s_tid=mwa_osa_a).
Thanks!
Eddie

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2020 年 8 月 26 日

1 投票

A Simulink model is made from Simulink blocks. The sum of all its Simulink blocks plus something else (configurations, parameters) becomes the Simulink model.
For simpler explaination, when you run a simulation of the model, the "InitFcn" of the model is executed first, then Simulink looks into all the blocks in the model to decide which block to execute first and which block to execute the next. If a block has an "InitFcn", then it is executed and goes to the next block. When all this "Initilization" is finished, the simulation begains, going step (in time) by step. In every time step, every block is executed at a particular order and this is repeated many times. All the "InitFcn" though, are executed only once per simulation during the "initizliaztion" period (sometime called compilation time).

3 件のコメント

Eddie Ball
Eddie Ball 2020 年 8 月 26 日
Thank you for the explination. I'm still a little confused tho. What happens when my block is a model (like a Subsystem or Subsystem Reference). I can set an InitFcn for the block, then go into the Subsystem and set an InitFcn for the model. What order are these InifFcn's run in?
Thanks!
Fangjun Jiang
Fangjun Jiang 2020 年 8 月 26 日
The best way to figure this out is to make an example. Display info into Command Window in the "InitFcn" to show it. There must be document describing the proper order. But again, might be harder to find it than making an example.
Eddie Ball
Eddie Ball 2020 年 8 月 26 日
That's a good idea. Thanks @Fangjun Jiang!

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

カテゴリ

ヘルプ センター および File ExchangeSubsystems についてさらに検索

製品

リリース

R2020a

質問済み:

2020 年 8 月 26 日

コメント済み:

2020 年 8 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by