필터 지우기
필터 지우기

How to change the parameter value at run time in Matlab Simulink

조회 수: 5 (최근 30일)
Maya
Maya 2024년 4월 8일
댓글: Fangjun Jiang 2024년 4월 9일
I want to change the input of model at run time.
Model and .m file is attached.
Input is coming from Switch block and Current (10) matlab parameter is connect to switch block defined in base workspace. Canc check in .m file.
The output of switch block goes to stateflow. In stateflow transition is[duration(Current>Current_TH)>0.2) than fault will set and if Current is less than Current_TH fault will clear.
Here Current value is 10 and Current_TH is 20.
Current_TH aslo i created as matlab parameter in base workspace.
How can change the current value at run time menas to set fault need to set current value greater than 21 and to clear fault current value less than 20 while running the model. How to make it happen at run time.
Please suggest any solution.
Thank you!!

답변 (2개)

Fangjun Jiang
Fangjun Jiang 2024년 4월 8일
This is not "change the parameter value at run time". Rather, it is to mimic a dynamic signal. You can use many of the blocks in the Simulink -> Sources library, for example, Step, Sine Wave, Signal Generator, etc.
The Step block changes the value once at a particular time. This could fit your need immediately.

Aquatris
Aquatris 2024년 4월 8일
I think what you are looking for is the dashboard, link here. It provides an interactive interface with a running model.
  댓글 수: 3
Aquatris
Aquatris 2024년 4월 9일
Then maybe this example is what you are looking for. It changes the value of a parameter in the simulink model on run time via matlab script.
Fangjun Jiang
Fangjun Jiang 2024년 4월 9일
Don't remember if the following feature is available in R2017a but you could try. It is available in recent versions.
Set the model to run simulation for a very long time or "inf", while the simulation is running, double click the Constant block with "Current" as the value, simply change the value to be 20 or 0.2 or whatever. Hit return and the new value will be used. This will help you debug the Stateflow chart.
If the need is to vary the value of "Current" to observe or debug the Stateflow, then replace the "Current" Constant block with a Step block or a Signal Generator block would be the solution. Setting the parameter to be tunable or settign the storage class is a completely wrong direction.

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

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by