Change Simulink.Parameter inside Simulink model

조회 수: 2 (최근 30일)
Jonas
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,
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.
Jonas
Jonas 2020년 6월 11일
Thank you for your advice!

댓글을 달려면 로그인하십시오.

추가 답변 (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