Is there any initialization block for parameters and constants in simulink model to be used throughout the model ?
4 次查看(过去 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!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 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 (한국어)