How can I realize an S-Function that can switch between having continuous states and discrete states based on the sample time inherited by the S-Function block in Simulink 7.3 (R2009a)?
6 views (last 30 days)
Show older comments
I would like to create an S-Function that has the ability to switch between being continuous and discrete. I set the ssSetNumContStates and ssSetNumDiscStates macros to DYNAMICALLY_SIZED and specify the real number of states in the mdlSetWorkWidths method. This does not work when the S-Function inherits a discrete sample time and I receive the following error message:
S-function edge in 'test_edge/S-Function' must have a continuous sample time since it has continuous states.
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
The ability to create an S-Function that can switch between having continous states and discrete states is currently not available in Simulink 7.3 (R2009a) and prior versions.
To workaround this issue you can specify a parameter for the S-Function block that will set the number of discrete and continuous states in the mdlInitializeSizes method of the S-Function:
if(!(*mxGetPr(ssGetSFcnParam(S,0))))
ssSetNumContStates(S, 1);
0 Comments
More Answers (0)
See Also
Categories
Find more on Event Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!