MATLAB: How to parameterize sample time in Model Reference Blocks in Simulink

ensuremodelreferencesamplesimulinktimetunable

I am trying to parameterize the sample time in my Model reference block. When I try to do so, I receive a warning stating the sample time parameter cannot be a tunable parameter.

Best Answer

This enhancement has been incorporated in Release 2012b (R2012b). For previous product releases, read below for any possible workarounds:
Model Reference can parameterize variables by defining them in the Model Workspace and then passing them in as instances to the model. Typically these passed in variables are "tunable' and can change during execution of the model.
For those algorithms where sample time is parameterized at initialization, this approach is not desirable when using model reference. If the algorithm implemented in the Model Reference Block is truly sample time independent (i.e. can be called at any rate), then the option in the Referenced Model Solver Pane can be set to 'Enforce Sample Time Independent'. Every instance this model is called, it will then inherit its sample time.
For those instances that the algorithm is still a function of some sample time (i.e. needs to be called as some specific rate).
The work around is to wrap a model reference block with a subsystem. The sample time restriction can be set at the inport blocks of the subsystem, while the value of sample time can also be passed to the Model Reference block if the algorithm needs it as well.
This approach would enforce that the Model Reference algorithm is called at the expected rate for each instance.