S-Function SimStruct Functions - MATLAB & Simulink (original) (raw)
About SimStruct Functions
The Simulink® software provides a set of functions for accessing the fields of an S-function's simulation data structure (SimStruct
). S-function callback methods use these functions to store and retrieve information about an S-function.
Language Support
Some SimStruct
functions are available only in some of the languages supported by the Simulink software. The reference page for each SimStruct
macro or function lists the languages in which it is available and gives the syntax for these languages.
Note
Most SimStruct
functions available in C are implemented as C macros. Individual reference pages indicate any SimStruct
macro that becomes a function when you compile your S-function in debug mode (mex -g
).
The SimStruct
The file [simstruc.h](https://mdsite.deno.dev/matlab:edit%28[matlabroot%20'/simulink/include/simstruc.h']%29;)
is a C language header file that defines the Simulink data structure and the SimStruct
access macros. It encapsulates all the data relating to the model or S-function, including block parameters and outputs.
There is one SimStruct
data structure allocated for the Simulink model. Each S-function in the model has its ownSimStruct
associated with it. The organization of theseSimStruct
s is much like a directory tree. TheSimStruct
associated with the model is the_root_ SimStruct
. The SimStruct
s associated with the S-functions are the child SimStruct
s.
SimStruct Macros and Functions Listed by Usage
- Buses
- Data Type
- Dialog Box Parameters
- Error Handling and Status
- Function Call
- Input and Output Ports
- Model Reference
- Run-Time Parameters
- Sample Time
- Simulation Information
- State and Work Vector
- Code Generation
- Miscellaneous
Buses
Data Type
Dialog Box Parameters
Error Handling and Status
Function Call
Input and Output Ports
I/O Port — Signal Specification
I/O Port — Signal Dimensions
Model Reference
Run-Time Parameters
These macros allow you to create, update, and access run-time parameters corresponding to a block's dialog parameters.
Sample Time
Simulation Information
Macro | Description |
---|---|
ssGetBlockReduction | Determine whether a block has requested block reduction before the simulation has begun and whether it has actually been reduced after the simulation loop has begun. |
ssGetErrorStatus | Get a character vector that identifies the last error. |
ssGetFixedStepSize | Get the fixed step size of the model containing the S-function. |
ssGetMaxStepSize | Get the maximum step size of the model containing the S-function. |
ssGetMinStepSize | Get the minimum step size of the model containing the S-function. |
ssGetSimMode | Determine the context in which an S-function is being invoked: normal simulation, external-mode simulation, model editor, etc. |
ssGetSimStatus | Determine the current simulation status. |
ssGetSolverMode | Get the solver mode being used to solve the S-function. |
ssGetSolverName | Get the name of the solver being used for the simulation. |
ssGetStateAbsTol | Get the absolute tolerance used by the model's variable-step solver for a specified state. |
ssGetStopRequested | Get the value of the simulation stop requested flag. |
ssGetT | Get the current base simulation time. |
ssGetTaskTime | Get the current time for a task. |
ssGetTFinal | Get the end time of the current simulation. |
ssGetTNext | Get the time of the next sample hit. |
ssGetTStart | Get the start time of the current simulation. |
ssIsExternalSim | Determine if the model is running in external mode. |
ssIsFirstInitCond | Determine whether the current simulation time is equal to the simulation start time. |
ssIsMajorTimeStep | Determine whether the current time step is a major time step. |
ssIsMinorTimeStep | Determine whether the current time step is a minor time step. |
ssIsVariableStepSolver | Determine whether the current solver is a variable-step solver. |
ssRTWGenIsAccelerator | Determine if the model is running in Accelerator mode. |
ssSetStateAbsTol | Set the values of the absolute tolerances that the variable-step solver will apply to the S-function states. |
ssSetBlockReduction | Request that Simulink attempt to reduce a block. |
ssSetOperatingPointCompliance | Specify how Simulink treats an S-function when saving and restoring the simulation state of a model containing the S-function. |
ssSetOperatingPointVisibility | Specify whether or not the simulation state of the S-function is visible (accessible) in the simulation state of the model. |
ssSetSolverNeedsReset | Ask Simulink to reset the solver. |
ssSetStopRequested | Ask Simulink to terminate the simulation at the end of the current time step. |