Documentation

Inspect Sample and Frame Rates in Simulink

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 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 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 signal is the quotient of the frame period and the frame size, M:

${T}_{s}={T}_{f}/M$

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

${T}_{si}={T}_{fi}/{M}_{i}$

${T}_{so}={T}_{fo}/{M}_{o}$

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

The illustration below shows a single-channel, frame 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/{T}_{fi}$. Similarly, the output frame rate would be $1/{T}_{fo}$.

The sample rate of a signal is the reciprocal of the sample period. For instance, the sample rate would be $1/{T}_{s}$.

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.

The block decides whether to process the signal one sample at a time or one frame at a time depending on the settings in the block dialog box. For example, a Biquad filter block with Input processing parameter set to Columns as channels (frame based) treats a 3-by-2 input signal as a two-frame signal with three samples in each frame. If Input processing parameter is set to Elements as channels (sample based), the 3-by-2 input signal is treated as a six-channel signal with one sample in each channel.

Inspect Signals Using the Probe Block

You can use the Probe block to display the sample period or the frame period of a signal. The Probe block displays the label Ts, the sample period or 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 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.

Display the Sample Period of a Signal Using the Probe Block

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

The Probe Example 1 model opens. Double-click the Signal From Workspace block. Note that the Samples per frame parameter is set to 1. 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 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.

Display the Frame Period of a Signal Using the Probe Block

1. At the MATLAB command prompt, type ex_probe_tut2.

The Probe Example 2 model opens. Double-click the Signal From Workspace block. Note that the Samples per frame parameter is set to 16. Each frame in the signal contains 16 samples. 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 has 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 frame 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 Signals Using Color Coding

View the Sample Rate of a Signal Using the Sample Time Color Coding

1. At the MATLAB command prompt, type ex_color_tut1.

The Sample Time Color Example 1 model opens. Double-click the Signal From Workspace block. Note that the Samples per frame parameter is set to 1. 2. In the Debug tab, select > . 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 signal in this model has a different sample rate. Therefore, each signal is assigned a different color.

View the Frame Rate of a Signal Using the Sample Time Color Coding

1. At the MATLAB command prompt, type ex_color_tut2.

The Sample Time Color Example 2 model opens. Double-click the Signal From Workspace block. Note that the Samples per frame parameter is set to 16. Each frame in the signal contains 16 samples. 2. To turn on sample time color coding, in the Debug tab, select > .

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 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 (Simulink).

Watch now