Guy and Seth on Simulink

November 20th, 2011

Sample Time Offset

I noticed that many users are not aware that it is possible to specify sample time offsets in Simulink.

Scalar Sample Time

In this simple model, I have specified the sample time of the Constant and the Discrete Integrator to 0.1s and the sample time of the Rate Transition block to 1s. This means that the Gain block will execute at time 0s, 1s, 2s, 3s, ...

Model with 2 rates

Sample Time Vector

What if I want the Gain block to execute at 0.4s, 1.4s, 2.4s, 3.4s, ... ?

As described in documentation section How to Specify the Sample Time, you can specify a sample time vector in the form [Ts, To] where Ts is the sample time and To is the initial time offset.

To apply an offset, I configure the Rate Transition:

Configuring the Rate Transition to have an offset

and the model now gives a different result. We now see that the Gain executes at a sample time of 1s, but with an offset of 0.4:

Sample Time Offset

Now it's your turn

Do you use sample time offset in your model? Leave us a comment here.

2 Responses to “Sample Time Offset”

  1. w w replied on :

    I know the offset but never try it.Can you tell me the relationship between the base rate and the sample time?
    Are they equal? Thank you.

  2. Guy Rouleau replied on :

    @ww: When we talk about “base rate”, we usually mean the fastest sample time in the model. In the example above, this is 0.1s.

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


MathWorks
Guy Rouleau and Seth Popinchalk are Application Engineers for MathWorks. They write here about Simulink and other MathWorks tools used in Model-Based Design.

These postings are the author's and don't necessarily represent the opinions of The MathWorks.