Passing information between level-2 matlab s-functions
Show older comments
I am trying to model a two step chemical process using simulink and s function for each step. 5 outputs from step 1 are connected to the 5 inputs of step 2. I initialize the outputs of step 1 in its s function using read in parameters. When I initialize the state variables of step 2, which uses outputs from step 1, the values of the output the output variables of step 1 inside step 2 initialization are zero. What can I do to fix this?
Thanks. Girish
Accepted Answer
More Answers (1)
Girish
on 12 Apr 2011
0 votes
4 Comments
Jarrod Rivituso
on 12 Apr 2011
Make sure you have defined continuous states if you want Simulink to numerically integrate them. The model "msfcndemo_limintm" has an example.
Some highlights from that are:
- Be sure to set the number of continuous states: block.NumContStates = 1;
- Be sure to register the derivatives block method: block.RegBlockMethod('Derivatives', @Derivative);
- Be sure to set the initial condition of the state in the InitConditions function: block.ContStates.Data = 1.5;
Girish
on 13 Apr 2011
Jarrod Rivituso
on 13 Apr 2011
Generally, continuous state blocks will have the following kind of flow during the simulation loop:
Outputs – creates the block output using the current value of the continuous state
Derivatives – creates the derivative of the block using the current value of the input signal, and possibly other factors as well
Girish
on 14 Apr 2011
Categories
Find more on Simulink in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!