How can I measure the model's sample time in a C-MEX S-function in Simulink 5.0 (R13)?
3 views (last 30 days)
Show older comments
I have a model in which I need to have access to the sample time of my model in an S-function.
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
This bug has been fixed in Release 2007b (R2007b). For previous product releases, read below for any possible workarounds:
This enhancement has been incorporated in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
We have verified that this information is missing from the Simulink documentation. As of Simulink 5.0 (R13), the macro ssGetFixedStepSize() can be used to find the fundamental sample time of a model. The usage is as follows:
*y = ssGetFixedStepSize(S); % Returns the Fixed-Step Size in y
Attached are fixed_step.mdl and fixed_step_size.c, which are an example model and an S-function that use this macro to display the fixed-step sample time.
Note that in order to use this (or any) macro in S-function builder, you must be using Simulink 6.2 (R14SP2) or later. If you are, then you can click the checkbox 'Enable access to SimStruct' on the 'Build Info' pane of S-function builder. Then you can use the syntax above wherever you need access to the fixed-step sample time.
0 Comments
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!