Borrar filtros
Borrar filtros

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

8 visualizaciones (últimos 30 días)
Maya el 8 de Abr. de 2024
Comentada: Fangjun Jiang el 9 de Abr. de 2024
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!!

Respuestas (2)

Fangjun Jiang
Fangjun Jiang el 8 de Abr. de 2024
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 el 8 de Abr. de 2024
I think what you are looking for is the dashboard, link here. It provides an interactive interface with a running model.
  3 comentarios
Aquatris el 9 de Abr. de 2024
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 el 9 de Abr. de 2024
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.

Iniciar sesión para comentar.


Más información sobre Simulink Functions en Help Center y File Exchange.




Community Treasure Hunt

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

Start Hunting!

Translated by