Creating States with a MATLAB Function Block
4 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2018 年 1 月 30 日
回答済み: MathWorks Support Team
2018 年 2 月 27 日
I want to include a Matlab algorithm in my model that has information which needs to persist over multiple time steps. Can I do this with a MATLAB Function block?
採用された回答
MathWorks Support Team
2018 年 1 月 30 日
It is possible to model state behavior using a MATLAB Function block, by declaring the state variable as 'persistent'. However, this is not the recommended workflow if you need information to persist through multiple time steps, since these blocks can only "fake" a state using a persistent variable. This is simple to implement, but has limitations since persistent variables cannot be logged, stored, or retrieved in Simulink.
There are several other options for implementing a MATLAB algorithm in Simulink. The following documentation page is a wonderful resource for comparing the different options for implementing a MATLAB algorithm in a Simulink model:
It is recommended to review this page before making a final choice about which block to use to implement your algorithm, since it discusses many considerations to make when choosing between the options (e.g. code generation, performance). The section on "Model State Behavior" discusses which options can work with states.
Finally, one option that is not mentioned on the above page is to use Stateflow.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Simulink Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!