User`s guide

Overview of the C MEX S-Function Routines
3-31
* of the output port which can be DYNAMICALLY_SIZE or greater than zero.
*/
if (!ssSetNumOutputPorts(S, nOutputPorts)) return;
ssSetOutputPortWidth(S, outputPortIdx, width);
/*
* Set the number of sample times. This must be a positive, nonzero
* integer indicating the number of sample times or it can be
* PORT_BASED_SAMPLE_TIMES. For multi-rate S-functions, the
* suggested approach to setting sample times is via the port
* based sample times routine. When you create a multirate
* S-function, care needs to be taking to verify that when
* slower tasks are preempted that your S-function correctly
* manages data as to avoid race conditions. When port based
* sample times are specified, the block cannot inherit a constant
* sample time at any port.
*/
ssSetNumSampleTimes( S, 1); /* number of sample times */
/*
* Set size of the work vectors.
*/
ssSetNumRWork( S, 0); /* number of real work vector elements */
ssSetNumIWork( S, 0); /* number of integer work vector elements*/
ssSetNumPWork( S, 0); /* number of pointer work vector elements*/
ssSetNumModes( S, 0); /* number of mode work vector elements */
ssSetNumNonsampledZCs( S, 0); /* number of nonsampled zero crossings */
/*
* Set any S-function options which must be OR'd together.
* The available options are:
* SS_OPTION_EXCEPTION_FREE_CODE - if your S-function does not use
* mexErrMsgTxt, mxCalloc, or any other routines which can throw an
* exception when called, you can set this option for improved
* performance.
*
* SS_OPTION_RUNTIME_EXCEPTION_FREE_CODE - Similar to
* SS_OPTION_EXCEPTION_FREE_CODE except it only applies to the "run-time"
* routines: mdlGetTimeOfNextVarHit, mdlOutputs, mdlUpdate, and
* mdlDerivatives.
*
* SS_OPTION_DISCRETE_VALUED_OUTPUT - This should be specified if your
* S-function has a discrete valued outputs. This is checked when
* your S-function is placed within an algebraic loop. If your S-function
* has discrete valued outputs, then its outputs will not be assigned
* algebraic variables.
*
* SS_OPTION_PLACE_ASAP - This is used to specify that your S-function
* should be placed as soon as possible. This is typically used by
* devices connecting to hardware.
*
* SS_OPTION_ALLOW_INPUT_SCALAR_EXPANSION - This is used to specify
* that the input to your S-function input ports can be either 1 or