How to use parameters from data dictionary in sinmulink's callback function?

i have a simulink model , and Desing data defined in Data Dictionary. now i want to initialize a variable by parameters from data dictionary in initFcn function. but it doesn't work:
Undefined function or variable 'x'. Variable 'x' does not exist.
what should i do?

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2022 年 10 月 13 日

0 投票

Use API to open the data dictionary and get the value, or the easiest thing to do is

2 件のコメント

Joe
Joe 2022 年 10 月 13 日
你好,我试过用api的话,生成的变量在workspace里面,但是因为模型选择了使用sldd,好像识别不了workspace里面的变量。所以报一样的错。我的目的是想用字典里已经存在的parameter去初始化一些参数。比如说我字典里有参数为轮胎的周长a,那么初始化的时候我得到半径:r = a/(2*pi)。
Fangjun Jiang
Fangjun Jiang 2022 年 10 月 13 日
Did you try Simulink.data.evalinGlobal()? There is also Simulink.data.assigninGlobal()

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

カテゴリ

ヘルプ センター および File ExchangeWorkspace Variables and MAT Files についてさらに検索

質問済み:

Joe
2022 年 10 月 13 日

コメント済み:

2022 年 10 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by