How can I model tunability on the sample time in Simulink Coder R2022b?

I have a discrete-time model made in Simulink R2022b. I am trying to make the sample time a variable property for embedding purposes. The sample time needs to be tunable for code generation purposes. Let us define an Inport block "In1" and a sample time variable "Ts", set as tunable in the Model Explorer. When attempting to build the model, the following error appears:
Parameter 'SampleTime' of 'Model/In1' is non-tunable but refers to tunable variables (Ts (base workspace))
However, running the model works without any issues.
How can I implement the tunability of the sample time?

 Accepted Answer

Tunable variables are currently not supported for the Sample Time property, since this property affects the performance of the entire model and model parts and workflow, such as block order, data transfers, sample time propagation, etc. The following Documentation page section provides more details about sample time propagation in Simulink:
To model tunability for a given sample time variable, defined as "Ts":
  • Set the solver type as "Fixed-step" and set the "Fixed-step size" value to "Ts". This property is found in Model Settings> Solver. 
  • In Solver>Solver Details>Tasking and sample time options, set the property "Periodic Sample Time Constraint" as "Ensure sample time independent". An error may appear informing about unsupported blocks. If so, please proceed to the next step. 
  • Make sure that the model is composed only by fundamental blocks. Some blocks like the "Discrete-Time Integrator" may need to be converted to their equivalent models with elemental blocks such as "gain", "sum", and "unit delay".
More information about performing these steps is available in the following MATLAB Documentation articles:

More Answers (0)

Categories

Find more on Deployment, Integration, and Supported Hardware in Help Center and File Exchange

Products

Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!