Level 2 MATLAB S-function - Initial Condition Input

In Simulink, I am trying to implement a continuous limited integrator where the output is bounded by lower and upper bounds and includes initial conditions, all of which are taken from input signals on the block rather than entered parameters.
I have used this blog post to help me understand how to limit the upper and lower bounds using input signals on the block. However, when I try to do the same for the initial conditions, it does not work.
I was trying:
function InitConditions(block)
block.ContStates.Data = block.InputPort(1).Data;
No initial condition is being implemented. I also tried "Start" functions with no such luck. Any help would be great!
Thanks -Brian

Answers (1)

Brian: I have explained here why S-functions do not have the ability to take the Initial Condition as an input. However, the Integrator block in Simulink does allow you to specify a signal as an Initial Condition (just select "external" for "Initial condition source" on the dialog). However, since this block does not allow input signals to specify the upper/lower bounds, I will recommend that you add a Saturation Dynamic block after the Integrator block, where you can specify input signals for the upper/lower bounds - the saturation limits will then be applied to the output of the Integrator block.

1 Comment

Thanks Kaustubha! The Saturation Dynamic block worked out well. I was unaware of this block in Simulink.

Sign in to comment.

Categories

Find more on Simulink in Help Center and File Exchange

Products

Asked:

on 18 Jul 2012

Community Treasure Hunt

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

Start Hunting!