Change Simulink.Parameter inside Simulink model

1 view (last 30 days)
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

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 11 Jun 2020
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 Comments
Fangjun Jiang
Fangjun Jiang on 11 Jun 2020
Then you can use Data Store Memory or global Goto/From block to ease the signal routing. Parameter won't serve your need.

Sign in to comment.

More Answers (0)

Categories

Find more on Manage Design Data in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!