How to change the initial condition of a block in the model with Simulink.Parameter?
조회 수: 11 (최근 30일)
이전 댓글 표시
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
답변 (2개)
Fangjun Jiang
2020년 1월 16일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Event Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!