How to set fixed values to Simulink parameters instead of variable?

6 ビュー (過去 30 日間)
Leonard Voss
Leonard Voss 2018 年 11 月 20 日
コメント済み: Leonard Voss 2018 年 11 月 20 日
Maybe there is an easy solution to this but i dont konw how to do it.
Lets say for example i do have a variable "a" with the value "2" in matlab and i want to set a gain block parameter to the value of "a" which is 2. Naturally i would write "a" into the parameter. If i do now save the Simulink model and use it later, it always requires a variable "a" in the Matlab Workspace. But i dont want it to be linked to the variable but instead to be actually the value of that variable.
Hope this is understandable.
This is just boiled down to an easy example.
I am searching for something like: set_param([...],'value',valueof(a))
Alternatively: instead of setting the fixed values to the simulink block parameters, is it posiible to save all necessary variables with the Simulink model?
Thanks.

採用された回答

Fangjun Jiang
Fangjun Jiang 2018 年 11 月 20 日
Not following your point. If you want the gain to be a, put in a. If you want the gain to be 2, put in 2.
You can add 'a' to the "Model Workspace", not the "Base Workspace". It will be saved with the model.
Open the "Model Explorer" (Ctrl+H), on the left panel, expand the root level model to see "Model Workspace"
  3 件のコメント
Fangjun Jiang
Fangjun Jiang 2018 年 11 月 20 日
Yes. Most block parameters need to be provided in the string format, not the numerical format.
You can use num2str(), mat2str(), int2str() for this purpose.
Leonard Voss
Leonard Voss 2018 年 11 月 20 日
Thank you very much mat2str() is what i was searching for.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgrammatic Model Editing についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by