Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

In frame-based processing, blocks process data one frame at a time. Each frame of data contains sequential samples from an independent channel. Each channel is represented by a column of the input signal. For example, from a frame-based processing perspective, the following 3-by-2 matrix has two channels, each of which contains three samples.

When you configure a block to perform frame-based processing,
the block interprets an *M*-by-1 vector as a single-channel
signal containing *M* samples per frame. Similarly,
the block interprets an *M*-by-*N* matrix
as a multichannel signal with *N* independent channels
and *M* samples per channel. For example, in frame-based
processing, blocks interpret the following sequence of 3-by-2 matrices
as a two-channel signal with a frame size of 3.

Using frame-based processing is advantageous for many signal processing applications because you can process multiple samples at once. By buffering your data into frames and processing multisample frames of data, you can often improve the computational time of your signal processing algorithms. To perform frame-based processing, you must have a DSP System Toolbox™ license.

For more information about the recent changes to frame-based
processing, see the Frame-based processing changes section of the *DSP System
Toolbox Release
Notes*.

The Signal From Workspace block creates a multichannel signal for frame-based
processing when the **Signal** parameter is a matrix, and the
**Samples per frame** parameter, *M*, is
greater than `1`

. Beginning with the first *M*
rows of the matrix, the block releases *M* rows of the matrix
(that is, one frame from each channel) to the output port every
*M***T _{s}* seconds.
Therefore, if the

The figure below is a graphical illustration of this process for a 6-by-4
workspace matrix, `A`

, and a frame size of 2.

Although independent channels are generally represented as columns, a single-channel signal can be represented in the workspace as either a column vector or row vector. The output from the Signal From Workspace block is a column vector in both cases.

In the following example, you use the Signal From Workspace block to create a three-channel frame signal and import it into the model:

Open the Signal From Workspace Example 5 model by typing

at the MATLAB

^{®}command line.dsp_examples_A = [1:100;-1:-1:-100]'; % 100-by-2 matrix dsp_examples_B = 5*ones(100,1); % 100-by-1 column vector

The variable called dsp_examples_

`A`

represents a two-channel signal with 100 samples, and the variable called dsp_examples_`B`

represents a one-channel signal with 100 samples.Also, the following variables are defined in the MATLAB workspace:

Double-click the Signal From Workspace block. Set the block parameters as follows, and then click

**OK**:**Signal**parameter to`[dsp_examples_A dsp_examples_B]`

**Sample time**parameter to`1`

**Samples per frame**parameter to`4`

**Form output after final data value**parameter to`Setting to zero`

Based on these parameters, the Signal From Workspace block outputs a signal with a frame size of 4 and a sample period of 1 second. The signal's frame period is 4 seconds. The

**Signal**parameter uses the standard MATLAB syntax for horizontally concatenating matrices to append column vector`dsp_examples_B`

to the right of matrix`dsp_examples_A`

. After the block has output the signal, all subsequent outputs have a value of zero.Run the model.

The figure below is a graphical representation of how your three-channel frame signal is imported into your model.

You have now successfully imported a three-channel frame signal into your model using the Signal From Workspace block.

The To Workspace and Triggered To Workspace blocks are
the primary blocks for exporting signals of all dimensions from a Simulink^{®} model to the MATLAB workspace.

A signal with *N* channels and frame size M is represented by
a sequence of *M*-by-*N* matrices. When this
signal is input to the To Workspace block, the block creates a
*P*-by-*N* array in the MATLAB workspace containing the *P* most recent samples
from each channel. The number of rows, *P*, is specified by the
**Limit data points to last** parameter. The newest
samples are added at the bottom of the matrix.

The following figure is a graphical illustration of this process for three
consecutive frames of a signal with a frame size of 2 that is exported to matrix
`A`

in the MATLAB workspace.

In the following example, you use a To Workspace block to export a three-channel signal with four samples per frame to the MATLAB workspace.

Open the Signal From Workspace Example 7 model by typing

`ex_exportfbsigs`

at the MATLAB command line.Also, the following variables are defined in the MATLAB workspace:

The variable called dsp_examples_

`A`

represents a two-channel signal with 100 samples, and the variable called dsp_examples_`B`

represents a one-channel signal with 100 samples.dsp_examples_A = [1:100;-1:-1:-100]'; % 100-by-2 matrix dsp_examples_B = 5*ones(100,1); % 100-by-1 column vector

Double-click the Signal From Workspace block. Set the block parameters as follows, and then click

**OK**:**Signal**=`[dsp_examples_A dsp_examples_B]`

**Sample time**=`1`

**Samples per frame**=`4`

**Form output after final data value =**`Setting to zero`

Based on these parameters, the Signal From Workspace block outputs a signal with a frame size of 4 and a sample period of 1 second. The signal's frame period is 4 seconds. The

**Signal**parameter uses the standard MATLAB syntax for horizontally concatenating matrices to append column vector`dsp_examples_B`

to the right of matrix`dsp_examples_A`

. After the block has output the signal, all subsequent outputs have a value of zero.Double-click the To Workspace block. Set the block parameters as follows, and then click

**OK**:**Variable name**=`dsp_examples_yout`

**Limit data points to last**=`inf`

**Decimation**=`1`

**Frames**=`Concatenate frames (2-D array)`

Based on these parameters, the To Workspace block exports its input signal to a variable called

`dsp_examples_yout`

in the MATLAB workspace. The workspace variable can grow indefinitely large in order to capture all of the input data. The signal is not decimated before it is exported to the MATLAB workspace, and each input frame is vertically concatenated to the previous frame to produce a 2-D array output.Run the model.

The following figure is a graphical representation of the model's behavior during simulation.

At the MATLAB command line, type

`dsp_examples_yout`

.The output is shown below:

dsp_examples_yout = 1 -1 5 2 -2 5 3 -3 5 4 -4 5 5 -5 5 6 -6 5 7 -7 5 8 -8 5 9 -9 5 10 -10 5 11 -11 5 12 -12 5

The frames of the signal are concatenated to form a two-dimensional array.

You have now successfully output a frame signal to the MATLAB workspace using the To Workspace block.

- Sample- and Frame-Based Concepts
- Create Signals for Sample-Based Processing
- Create Signals for Frame-Based Processing
- Create Multichannel Signals for Sample-Based Processing
- Create Multichannel Signals for Frame-Based Processing
- Deconstruct Multichannel Signals for Sample-Based Processing
- Deconstruct Multichannel Signals for Frame-Based Processing
- Import and Export Signals for Sample-Based Processing
- Inspect Sample and Frame Rates in Simulink
- Convert Sample and Frame Rates in Simulink