Parsing big structures to simulink fails??

1 回表示 (過去 30 日間)
Nicolò Badodi
Nicolò Badodi 2020 年 12 月 2 日
コメント済み: Nicolò Badodi 2020 年 12 月 3 日
I am trying to simulate a system that requires a lot of parameters to be loaded into Simuink.
These parameters are organized in a structure of the type:
constants
---> body1
---> value1
---> value2
---> ....
---> property 3
---> value1
---> value2
---> ...
---> body2
---> ....
---> ...
The structure is quite complex but all the values are constant.
What I'm doing now is running a script that defines this structure, and then I use the Simulink.Bus.CreateObject(constants) to generate a bus object bound to a "constant" block in Simulink.
Oddly enough the Simulink.Bus.CreateObject unpacks my struct and creates many objects, from various depths of my structure.
Any idea of I could import this damned structure to simulink??

採用された回答

Sara Nadeau
Sara Nadeau 2020 年 12 月 2 日
Loading data for a bus into Simulink involves two parts: the data itself and a definition of the bus data type.
For the data itself, you use your structure. The Bus object(s) you're creating define the bus data type. I believe you're seeing more than one bus object because your structure includes nested structures (which correspond to a nested bus). With a nested bus, you need to define the data type for that element of the bus using another Bus object.
To use your structure in the Constant block, you should be able to specify the value using the name of the variable in the workspace (could be base workspace or model workspace) with the structure data and then define the Output data type as Bus: myBusObject where myBusObject is the name of the Bus object for the top-level bus. You'll find the Output data type parameter for the Constant block on the Signal Attributes tab of the block dialog.
  1 件のコメント
Nicolò Badodi
Nicolò Badodi 2020 年 12 月 3 日
Thanks!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by