Writing S-Functions | ![]() ![]() |
S-Function Outputs
An M-file returns an output vector containing the following elements:
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 (an 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
, a two column matrix containing the sample times and offsets of the block. Continuous systems have their sample time set to zero. The hybrid example, which starts on page 2-13, 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];
![]() | S-Function Arguments | Defining S-Function Block Characteristics | ![]() |