MATLAB: Are the sample times obtained in Simulink 7.8 (R2011b) different from those calculated in previous releases for the model with ‘Inline parameters’ unchecked

simulinktaskingTS

When I simulate a model that was originally created in Simulink 7.7 (R2011a), or previous releases, in R2011b I obtain different sample times that affect the results of my simulation.

Best Answer

This is an expected behavior in Simulink 7.8 (R2011b). This has been introduced with the goal of minimizing the sample time propagation changes when toggling the "Inline Parameters" setting in Optimization -> Signals and Parameters.
In previous releases the "Inline Parameters" option was influencing the way heuristic sample times were defined. This was leading to different sample times depending on this "Inline Parameters" option.
If Inline parameters was ON for your model, your model is not affected by this change and you will obtain the same sample time values. If Inline parameters was OFF in your model your sample times may be affected by this change. Typically you may obtain different sample times when source blocks have inherited sample times.
If you prefer the sample time propagation results from R2011a and earlier with Inline parameters OFF, you can ensure the desired sample times by manually specifying them on the affected block. If the block does not have a sample time parameter, use the Signal Specification block to specify sample times on the input or output signal.
The function “checkSampleTimeChangesIn11b”, attached to this solution, can be used to check which blocks in your model may be affected by this change. This function generates a MAT file when run in R2011a or before for storing the sample time data to be used for comparison in R2011b. The MAT file will be named based on the model name (in example, for the model my_model.mdl, the MAT file would be SampleTimeChangesFormy_model.mat).
1) Download the function “checkSampleTimeChangesIn11b” in a folder included in your MATLAB path
2) Open MATLAB R2011a and execute the command:
checkSampleTimeChangesIn11b('my_model');
where my_model is the name of the Simulink model you are analyzing. This command will create the file SampleTimeChangesFormy_model.mat.
3) Open MATLAB R2011b and execute the command again:
check_results = checkSampleTimeChangesIn11b('my_model');
The function will then return a structure array summarizing the differences. Each element of the array is referring to a specific block where there is a difference and contains two main fields R2011b and R2011a. The substructure:
blk = Block path
blkTS = Block sample time
inputPortTs = Input ports sample time
outputPortTS = Output ports sample time
allows you to compare the block sample time changes.
As an example please consider this specific case.
In R2011a or previous releases with "Inline Parameters" setting OFF:
In R2011b or previous releases with "Inline Parameters" setting ON:
As shown in previous images, for some models Simulink would determine this different approach was leading to different sample times depending on the "Inline Parameters" option. If the option was OFF in R2011a the model is subject to sample time changes when moving to R2011b.
By using the function attached to this solution you can obtain an analysis of the changes. As an example the output of the test for the downsample block is reporting the change:
R2011a or before:
blk: 'ex_model/Probe1'
blkTs: [0.6667 0]
inputPortTs: {[0.6667 0]}
outputPortTs: {[0.6667 0]}
R2011b:
blk: 'ex_model/Probe1'
blkTs: [2 0]
inputPortTs: {[2 0]}
outputPortTs: {[2 0]}