User`s guide
Introduction
1-11
• Continuous sample time — For S -functions that have continuous states and/
ornonsampled zerocrossings.Fort his typeof S-function,theoutputchanges
in minor time steps.
• Continuous but fixed in minor time step sample t ime — For S-functions that
need to execute at every major simulation step, but do not change value
during minor time steps.
• Discrete sample time — If your S-Function block’s behavior is a function of
discrete time intervals, you can define a sample time to control when
Simulink calls the block. You can also define an offset that delays each
sample time hit. The value of the offset cannot exceed the corresponding
sample time.
A sample time hit occurs at time values determined by this formula
TimeHit = (n * period) + offset
where n, an integer, is the current simulation step. The first value of n is
always zero.
Ifyoudefinea discretesampletime,Simulink calls theS-functio n
mdlOutput
and mdlUpdate routines at each sample time hit (as defined in the above
equation).
• Variable sample time — A discretesample time where the intervals between
sample hits can vary. At the start of each simulation step, S-functions with
variable sample times are int egrated for the time of next hit.
• Inherited sample time — Sometimes an S-Function block has no inherent
sample time characteristics (that is, it is either continuous or discrete,
depending on the sample time of some other block in t he system). You can
specify that the block’s sample time is inherited. A simple example of this is
a Gain block that inherits its sample ti me from the block driving it.
A block can inherit its sample time from:
- The driving block
- The destination block
- The fastest sample time in the system
Toset abl ock’s samplet ime as inherited,use-1 as thesample time.Formore
information on the propagationof sample times,see “Sample Time Colors”in
Using Simulink.