How to change the parameter value at run time in Matlab Simulink
5 次查看(过去 30 天)
显示 更早的评论
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!!
0 个评论
回答(2 个)
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.
0 个评论
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
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
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 Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!