Main Content

S-Function Compliance with the ModelOperatingPoint

ModelOperatingPoint Compliance Specification for C MEX S-Functions

As with the MATLAB® S-function, your C MEX S-function code must inform Simulink® of the S-function compliance with the ModelOperatingPoint feature. You can accomplish this task by using the S-function API, ssSetOperatingPointCompliance.

In most cases, specifying the compliance to be default is sufficient to save and restore the necessary state data. To specify the default compliance, add this line:

ssSetOperatingPointCompliance(S, USE_DEFAULT_OPERATING_POINT).

The options are as follows:

OPERATING_POINT_COMPLIANCE_UNKNOWNThis is the default setting for all S-functions. For S-functions that do not use PWorks, Simulink saves and restores the default simulation operating point (see USE_DEFAULT_OPERATING_POINT) and issues a warning to inform the user of this assumption. On the other hand, Simulink reports an error during the save and restore if it encounters an S-function that uses PWorks.
USE_DEFAULT_OPERATING_POINTThis setting instructs Simulink to treat the S-function like a built-in block when saving and restoring the ModelOperatingPoint object. This setting saves continuous states, non-scratch Dworks, and zero crossing signal information

This setting informs Simulink that the S-function does not have any simulation state. With this setting, no state information is saved for this block. This setting is primarily useful for "sink" blocks (i.e., blocks with no output ports) that use PWorks or DWorks to store handles to files or figure windows.


This setting is not allowed if the S-function registers any discrete or continuous states or zero crossing signals.

DISALLOW_OPERATING_POINTThis setting informs Simulink that the S-function does not allow the saving or restoring of its operating point. Simulink reports an error if you try to save or restore the ModelOperatingPoint object of the model that contains this S-function. You can use this setting if the S-function communicates with a 3rd party library and state serialization is not possible.
USE_CUSTOM_OPERATING_POINTThis setting informs Simulink that the S-function has mdlGetOperatingPoint and mdlSetOperatingPoint methods.

For S-functions that use PWork vectors or static variables to hold data that Simulink updates during simulation, the S-function must use the custom mdlGetOperatingPoint and mdlSetOperatingPoint methods. The following statements demonstrate the proper format.

mxArray* mdlGetOperatingPoint(SimStruct* S)
void mdlSetOperatingPoint(SimStruct* S, const mxArray* inSS)

For an example of how to implement these methods, see Custom Code and Hand Coded Blocks Using the S-function API.

See Also

| | | | |

Related Topics