現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
Is there any initialization block for parameters and constants in simulink model to be used throughout the model ?
1 回表示 (過去 30 日間)
古いコメントを表示
Hi, I know that writting this in matlab script is a way to do it and also creating a variable from simulink is also a way to do it. I think these 2 methods are not neat. I would like to do the opposite have a block to do, initialize all the parameters and constants of the model in simulink. Please let me know what are the ways to do it.
採用された回答
Fangjun Jiang
2023 年 9 月 29 日
Use a Simulink Data Dictionary (.sldd). Start from here
17 件のコメント
VIGNESH BALAJI
2023 年 10 月 27 日
I am very confused of how to do it. I read the post and also saw video on youtube.
I am using MATLAB 2021b and I am unable to get this step -
- In the Simulink Editor, on the Modeling tab, under Design, click Link to Data Dictionary.
Can you please show me where to find it ?
Fangjun Jiang
2023 年 10 月 27 日
The UI for each version might be different. At the "Design" group, press the "down arrow".


VIGNESH BALAJI
2023 年 10 月 27 日
I don't understand the point number 10 either
- To open the dictionary, in the Simulink Editor, click the model data badge in the bottom left corner, then click the External Data link. To inspect the contents of the dictionary, in the Model Explorer Model Hierarchy pane, under the External Data node, expand the dictionary node.
I have attached a picture of this

VIGNESH BALAJI
2023 年 10 月 27 日
@Fangjun Jiang From my understanding it looks like, I cannot add / create new variables or constants directly in Data Dictionary. Am I correct ?
Fangjun Jiang
2023 年 10 月 27 日
Yes you can. Open the 'sldemo_fuelsys_dd' demo model. Click the data dictionary icon on the low left corner of the model canvas, and then

VIGNESH BALAJI
2023 年 10 月 27 日
@Fangjun Jiang Thanks a lot for the answer. I got it and able to add new variable / data.
I have a question, Is it possible to use this variable or data inside Matlab Function block directly ? without sending as an input port value to the block and directly using it inside the block as it is in the simulink workspace ?
Fangjun Jiang
2023 年 10 月 27 日
Yes. Inside the MATLAB Function block, add a data, specify it as a "parameter".
VIGNESH BALAJI
2023 年 10 月 27 日
@Fangjun Jiang If I add it a parameter inside the Matlab function block, Will it be automatically be present in my data dictionary ? Can I also use it in other places of my simulink model ?
Did you mean the steps followed in this link - Create and Define MATLAB Function Block Variables - MATLAB & Simulink - MathWorks Benelux
Can you please show a screenshot of it ? I am unable to see that in MATLAB 2021b.
Fangjun Jiang
2023 年 10 月 27 日
For R2021b, see https://www.mathworks.com/help/releases/R2021b/simulink/ug/parameter-arguments-in-matlab-function-block-functions.html
That "parameter" has to come from base workspace, or model worspae, or data dictionary. It can be used anywhere in the model.
VIGNESH BALAJI
2023 年 10 月 27 日
@Fangjun Jiang I am unable to find the Ports & Data Manager block to do this change. Can you please show a screenshot of it. I have been trying this for a long time.
Fangjun Jiang
2023 年 10 月 28 日
移動済み: Fangjun Jiang
2023 年 10 月 28 日
The button on the top left corner, second image, on this link
VIGNESH BALAJI
2023 年 10 月 30 日
I looked at the image in the same function tab and I don't find the Ports & Data tab anywhere. I have attached a screenshot of it. I also read in other questions that it only shows up while we edit and I tried it too, It didn't come up.

Fangjun Jiang
2023 年 10 月 30 日
No idea. You might have customized toolstrip.
In Simulink, press Ctrl+H to bring up Model Explorer, navigate to the MATLAB Function block on the left. On the right, it is the same UI.
VIGNESH BALAJI
2023 年 10 月 30 日
I have not customised anything atleast knowingly. If you know how to bring back the standard toolbar, let me know. I followed the steps through model explorer and it worked. I need to first add it in External data and mention in function block as a parameter and also have it as an argument to the function.
Thanks and it worked :)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Interactive Model Editing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)