Simulink + How to change tuning parameters (Gain parameters) during simulation at predefined time steps

1 view (last 30 days)
I am using a fixed-step solver (ode4) with a fixed step size. I need to change the gain parameter of the Gain Function Block at predefined time steps during the simulation. Thereby the dimensions of the vectors or matrix (gain parameter) could also be changed.
The time where the change should happen is defined in the initial M-file in the workspace.
More precise: I would like to switch between different state space representations during a simulation, like
\Dot{x} = A x + B u
Y = C x + D u
To summarize – A, B, C and D should be updated at the predefined time step.
I tried to do this with set_param() but I wasn’t successful. Thanks in advance for any help.
Joe

Answers (1)

Jorik
Jorik on 9 Dec 2013
Edited: Jorik on 9 Dec 2013
If your parameters will really cause a difference of dimensions, it will only be possible to do this with variable-size signals instead of changing parameters while running the simulation. At Model Update (Initialization) blocks like a Gain will get fixed dimensions. It is not possible to change these dimensions during a simulation.
Instead you need to work with variable-size signals. There is quite a bit of good documentation about this and you may want to start reading here if this is new to you: http://www.mathworks.com/help/simulink/ug/variable-size-signal-basics.html
You could use a Multiply block instead of the Gain block and then you can have a Switch that switches between different "parameter" values at a predefined time (comparison with a Clock block). You could also program the logic of changing values and sizes in a MATLAB Function block.

Categories

Find more on Configure Simulation Conditions in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!