Contents

Create C/C++ S-Functions

Write S-functions using C or C++ code

Blocks

S-Function Include S-function in model
S-Function Builder Create S-function from C code that you provide

S-Function Callback Methods

mdlInitializeSizes Specify the number of inputs, outputs, states, parameters, and other characteristics of the C MEX S-function
mdlInitializeSampleTimes Specify the sample rates at which this C MEX S-function operates
mdlOutputs Compute the signals that this block emits
mdlTerminate Perform any actions required at termination of the simulation
mdlCheckParameters Check the validity of a C MEX S-function's parameters
mdlDerivatives Compute the C MEX S-function's derivatives
mdlDisable Respond to disabling of an enabled system containing this block
mdlEnable Respond to enabling of a enabled system containing this block
mdlGetSimState Return the C MEX S-function simulation state as a valid MATLAB data structure, such as a matrix structure or a cell array.
mdlGetTimeOfNextVarHit Specify time of the next sample time hit
mdlInitializeConditions Initialize the state vectors of this C MEX S-function
mdlProcessParameters Process the C MEX S-function's parameters
mdlProjection Perturb the solver's solution of a system's states to better satisfy time-invariant solution relationships
mdlRTW Generate code generation data for a C MEX S-function
mdlSetDefaultPortComplexSignals Set the numeric types (real, complex, or inherited) of ports whose numeric types cannot be determined from block connectivity
mdlSetDefaultPortDataTypes Set the data types of ports whose data types cannot be determined from block connectivity
mdlSetDefaultPortDimensionInfo Set the default dimensions of the signals accepted or emitted by a C MEX S-function's ports
mdlSetInputPortComplexSignal Set the numeric types (real, complex, or inherited) of the signals accepted by an input port
mdlSetInputPortDataType Set the data types of the signals accepted by an input port
mdlSetInputPortDimensionInfo Set the dimensions of the signals accepted by an input port
mdlSetInputPortDimensionsModeFcn Propagate the dimensions mode
mdlSetInputPortFrameData Specify whether an input port accepts frame data
mdlSetInputPortSampleTime Set the sample time of an input port that inherits its sample time from the port to which it is connected
mdlSetInputPortWidth Set the width of an input port that accepts 1-D (vector) signals
mdlSetOutputPortComplexSignal Set the numeric types (real, complex, or inherited) of the signals accepted by an output port
mdlSetOutputPortDataType Set the data type of the signals emitted by an output port
mdlSetOutputPortDimensionInfo Set the dimensions of the signals accepted by an output port
mdlSetOutputPortSampleTime Set the sample time of an output port that inherits its sample time from the port to which it is connected
mdlSetOutputPortWidth Set the width of an output port that outputs 1-D (vector) signals
mdlSetSimState Set the simulation state of the C MEX S-function by restoring the SimState.
mdlSetWorkWidths Specify the sizes of the work vectors and create the run-time parameters required by this C MEX S-function
mdlSimStatusChange Respond to a pause or resumption of the simulation of the model that contains this C MEX S-function
mdlStart Initialize the state vectors of this C MEX S-function
mdlUpdate Update a block's states
mdlZeroCrossings Update zero-crossing vector

Was this topic helpful?