MATLAB Answers

Change Simulink.Parameter inside Simulink model

9 ビュー (過去 30 日間)
Jonas 2020 年 6 月 11 日
コメント済み: Jonas 2020 年 6 月 11 日
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,


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 件のコメント
Jonas 2020 年 6 月 11 日
Thank you for your advice!


その他の回答 (0 件)




Community Treasure Hunt

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

Start Hunting!

Translated by