Contents

Inspect Sample and Frame Rates in Simulink

    Note:   Starting in R2010b, many DSP System Toolbox™ blocks received a new parameter to control whether they perform sample- or frame-based processing. The following content has not been updated to reflect this change. For more information, see the Frame-Based Processing section of the Release Notes.

Sample Rate and Frame Rate Concepts

Sample rates and frame rates are important issues in most signal processing models. This is especially true with systems that incorporate rate conversions. Fortunately, in most cases when you build a Simulink® model, you only need to set sample rates for the source blocks. Simulink automatically computes the appropriate sample rates for the blocks that are connected to the source blocks. Nevertheless, it is important to become familiar with the sample rate and frame rate concepts as they apply to Simulink models.

The input frame period (Tfi) of a frame-based signal is the time interval between consecutive vector or matrix inputs to a block. Similarly, the output frame period (Tfo) is the time interval at which the block updates the frame-based vector or matrix value at the output port.

In contrast, the sample period, Ts, is the time interval between individual samples in a frame, this value is shorter than the frame period when the frame size is greater than 1. The sample period of a frame-based signal is the quotient of the frame period and the frame size, M:

Ts=Tf/M

More specifically, the sample periods of inputs (Tsi) and outputs (Tso) are related to their respective frame periods by

Tsi=Tfi/Mi

Tso=Tfo/Mo

where Mi and Mo are the input and output frame sizes, respectively.

The illustration below shows a single-channel, frame-based signal with a frame size (Mi) of 4 and a frame period (Tfi) of 1. The sample period, Tsi, is therefore 1/4, or 0.25 second.

The frame rate of a signal is the reciprocal of the frame period. For instance, the input frame rate would be 1/Tfi. Similarly, the output frame rate would be 1/Tfo.

The sample rate of a signal is the reciprocal of the sample period. For instance, the sample rate would be 1/Ts.

In most cases, the sequence sample period Tsi is most important, while the frame rate is simply a consequence of the frame size that you choose for the signal. For a sequence with a given sample period, a larger frame size corresponds to a slower frame rate, and vice versa.

Inspect Sample-Based Signals Using Probe Block

You can use the Probe block to display the sample period of a sample-based signal. For sample-based signals, the Probe block displays the label Ts, the sample period of the sequence, followed by a two-element vector. The left element is the period of the signal being measured. The right element is the signal's sample time offset, which is usually 0.

    Note   Simulink offers the ability to shift the sample time of a signal by an arbitrary value, which is equivalent to shifting the signal's phase by a fractional sample period. However, sample-time offsets are rarely used in signal processing systems, and DSP System Toolbox blocks do not support them.

In this example, you use the Probe block to display the sample period of a sample-based signal:

  1. At the MATLAB® command prompt, type ex_probe_tut1ex_probe_tut1.

    The Probe Example 1 model opens.

  2. Run the model.

    The figure below illustrates how the Probe blocks display the sample period of the signal before and after each upsample operation.

    As displayed by the Probe blocks, the output from the Signal From Workspace block is a sample-based signal with a sample period of 1 second. The output from the first Upsample block has a sample period of 0.5 second, and the output from the second Upsample block has a sample period of 0.25 second.

Inspect Frame-Based Signals Using Probe Block

You can use the Probe block to display the frame period of a frame-based signal. For frame-based signals, the block displays the label Tf, the frame period of the sequence, followed by a two-element vector. The left element is the period of the signal being measured. The right element is the signal's sample time offset, which is usually 0.

    Note   Simulink offers the ability to shift a signal's sample times by an arbitrary value, which is equivalent to shifting the signal's phase by a fractional sample period. However, sample-time offsets are rarely used in signal processing systems, and DSP System Toolbox blocks do not support them.

In this example, you use the Probe block to display the frame period of a frame-based signal:

  1. At the MATLAB command prompt, type ex_probe_tut2ex_probe_tut2.

    The Probe Example 2 model opens.

  2. Run the model.

    The figure below illustrates how the Probe blocks display the frame period of the signal before and after each upsample operation.

    As displayed by the Probe blocks, the output from the Signal From Workspace block is a frame-based signal with a frame period of 16 seconds. The output from the first Upsample block has a frame period of 8 seconds, and the output from the second Upsample block has a sample period of 4 seconds.

Note that the sample rate conversion is implemented through a change in the frame period rather than the frame size.

Inspect Sample-Based Signals Using Color Coding

In the following example, you use sample time color coding to view the sample rate of a sample-based signal:

  1. At the MATLAB command prompt, type ex_color_tut1ex_color_tut1.

    The Sample Time Color Example 1 model opens.

  2. From the Display menu, point to Sample Time, and select Colors.

    This selection turns on sample time color coding. Simulink now assigns each sample rate a different color.

  3. Run the model.

    The model should now look similar to the following figure:

    Every sample-based signal in this model has a different sample rate. Therefore, each signal is assigned a different color.

For more information about sample time color coding, see View Sample Time Information in the Simulink documentation.

Inspect Frame-Based Signals Using Color Coding

In this example, you use sample time color coding to view the frame rate of a frame-based signal:

  1. At the MATLAB command prompt, type ex_color_tut2ex_color_tut2.

    The Sample Time Color Example 2 model opens.

  2. To turn on sample time color coding, from the Display menu, point to Sample Time, and select Colors.

    Simulink now assigns each frame rate a different color.

  3. Run the model.

    The model should now look similar to the following figure:

    Because the Rate options parameter in the Upsample blocks is set to Allow multirate processing, each Upsample block changes the frame rate. Therefore, each frame-based signal in the model is assigned a different color.

  4. Double-click on each Upsample block and change the Rate options parameter to Enforce single-rate processing.

  5. Run the model.

    Every signal is coded with the same color. Therefore, every signal in the model now has the same frame rate.

For more information about sample time color coding, see View Sample Time Information in the Simulink documentation.

Was this topic helpful?