Change Simulink.Parameter inside Simulink model

2 次查看(过去 30 天)
Hi all
I am using Simulink.Parameter objects stored inside a Data Dictionary to parameterize my model. They have a default value which is used during simulation. How can I change the value of a Simulink.Parameter from inside my Simulink model, with a block?
My use-case is that I am using a Simulink.Parameter 'Rs' for the stator resistance of a motor. It has a default value, but I have an algorithm performing an estimation procedure which results in an updated value and I want to store that output as the new value of the Simulink.Parameter 'Rs'.
Could I use Data Store blocks or something like this? I do not want to disturb the accessibility of the Simulink.Parameters in other parts of the model.
Or are S-functions the solution?
With kind regards,
Jonas

采纳的回答

Fangjun Jiang
Fangjun Jiang 2020-6-11
It will be hard to "change the value of a Simulink.Parameter from inside of my Simulink model", if not possible. Even if you could, the changed value won't take effect during simulation if it was used by the Constant block.
You could use a Data Store, which requires (implictly or explictly) a Simulink.Signal object, which is basically the same effect as the approach below.
Get rid of the "Rs" Constant block. Connect the estimated "Rs" output to the output of that Constant block. Label the signal as "DynamicRs" and check the signal property, "Signal name must resolve to Simulink signal object".
In your data dictionary, create a Simulink.Signal object named "DynamicRs" and you can set up the initial value, which is your Rs value.
The point here is that your "Rs" is truly a dynamic signal. Only its initial value is a parameter.
  3 个评论
Fangjun Jiang
Fangjun Jiang 2020-6-11
Then you can use Data Store Memory or global Goto/From block to ease the signal routing. Parameter won't serve your need.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Sources 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by