How to change the initial condition of a block in the model with Simulink.Parameter?
13 views (last 30 days)
Show older comments
Hello,
I want to change the initial condition of a Simulink block, like "Unit Delay" or in my case Biquad-Filter of the DSP System Toolbox. I want to set up the initial condition of the filter with the first valid value in order that the filter is faster at the designated value. In the model, the initial condition is not a constant and can varying at every system start or simulation run. It is not possible to set up this parameter in the properties as an input port. So I have to create an Simulink.Parameter in the Model Workspace for this initial condition. How can I set or write this Simulink.Parameter during the Simulation in the Simulink-model? I found a solution to set it via MATLAB or Command Window but not in Simulink. Has somenone an solution for this issue? Is there an alternative way?
In addition I have to generate C-Code with the Embedded Coder of this filter. So the solution might be work with the Embedded Coder as well and it should not be a global variable. The calculation and the setting of the initial condition are in one function, so that it should be sufficient a local variable.
Thanks a lot in advance!
Mario
0 Comments
Answers (2)
Fangjun Jiang
on 16 Jan 2020
The initial condition can be regarded as a state. Use the "State Writer" block. Follow examples.
https://www.mathworks.com/help/releases/R2019b/simulink/slref/statewriter.html
See Also
Categories
Find more on Event Functions 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!