How do I get stateflow to use parameters in Simulink.parameter object?

22 ビュー (過去 30 日間)
Ebbe Nielsen
Ebbe Nielsen 2020 年 3 月 20 日
コメント済み: Ebbe Nielsen 2020 年 3 月 24 日
Hi,
I have been looking around for a answer to this but have not found any concrete usefull information.
I have a simulink model containing a stateflow chart. In this stateflow chart I would like to use parameters from a Simulink.parameter object. I will be building the model using ert_shrlib target.
The struct looks like this:
Futhermore i have a bus defined like this (it has the two parameters im using in my test setup):
I have tried to look at the example sf_bus_demo but that seems to build the bus in simulink and then pass it to Stateflow via an input. What i would like to do is to make the parameters available in stateflow like done with non-simulink.parameters objects (see picture below):
I have tried to mess arround with adding the "ParamStruct" bus but have not been able to get it to work.
I can't seem to figure out how to do this. Maybe my understanding of how to approach this is not correct?
I have attached the small test setup im trying to get to work.
Thanks,
Ebbe Nielsen

採用された回答

Fangjun Jiang
Fangjun Jiang 2020 年 3 月 20 日
If you add a "data1" in Stateflow and specify its scope as "Parameter" and "Type" (meaning data type) as "Inherit: same as Simulink", it will automatically look for the variable "data1" in base workspace (or data dictionrary). You can then define "data1" as a Simulink.Parameter object. They will be linked.
Your "ParamStruct" is a Simulink.Bus object. In that case, define it in base workspace. In Stateflow, when you add data, specify the "type" as "Bus: ParamStruct".
  1 件のコメント
Ebbe Nielsen
Ebbe Nielsen 2020 年 3 月 24 日
Thank you very much Fangjun Jiang. This seemed to lead me on the correct path to get it to work.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Functions についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by