User`s guide

Introduction
2-5
The first four input arguments, which Simul ink passes to the S-function,must
be the variables
t, x, u,andflag:
t, the time
x, the state vector (required even if, as in this case, there are no states)
u,theinputvector
flag, the parameter that controls the S-function subroutine calls at each
simulation stage
Simulink also requires that the output parameters,
sys, x0, str,andts be
placed in the order given. These parameters are:
sys, a generic return argument. The values returned depend on the flag
value. For example, for
flag = 3, sys contains the S-function outputs.
x0, the initial state values (a n empty vector if there are no states in the
system).
x0 is ignored, except when flag = 0.
str, reserved for future use. M-file S-functions must set this to the empty
matrix,
[].
ts, atwo column matrix containingthe sample times andoffsets of theblock.
Continuoussystems have their sample time set to zero. The hybrid example,
which starts on page 2-14, demonstrates an S-function with multiple sample
times.
Sample times should be declared in ascending order. For example, if you
want your S-function to execute at [0 0.1 0.25 0.75 1.0 1.1 1.25, etc.], set
ts
equal to a two row matrix:
ts = [.25 0; 1.0 .1];
For more discussion of sample times, see “Sample Time Colors” in Using
Simulink.