Change Simulink.Parameter inside Simulink model

1 Ansicht (letzte 30 Tage)
Jonas
Jonas am 11 Jun. 2020
Kommentiert: Jonas am 11 Jun. 2020
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

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 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 Kommentare
Fangjun Jiang
Fangjun Jiang am 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.
Jonas
Jonas am 11 Jun. 2020
Thank you for your advice!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Manage Design Data finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by