| Signal Processing Blockset™ | ![]() |
Signal Processing Sinks
dspsnks4
The Signal To Workspace block writes data from your simulation into an array in the MATLAB main workspace. The output array can be 2-D or 3-D, depending on whether the data is 1-D, sample based, or frame based. The Signal To Workspace block and the Simulink To Workspace block can output the same arrays when their parameters are set appropriately.
For more information on the Signal To Workspace block, see the following sections of this reference page:
The Variable name parameter is the name of the array in the MATLAB workspace into which the block logs the simulation data. The array is created in the workspace only after the simulation stops running. When you enter the name of an existing workspace variable, the block overwrites the variable with an array of simulation data after the simulation stops running.
When the block input is sample based or 1-D, the Limit data points to last parameter indicates how many samples of data to save. When the block input is frame based, this parameter indicates how many frames of data to save. When the simulation generates more than the specified maximum number of samples or frames, the simulation saves only the most recently generated data. To capture all data, set Limit data points to last to inf.
The Decimation parameter is the decimation factor. It can be set to any positive integer d, and allows you to write data at every dth sample. The default decimation, 1, writes data at every time step.
The Frames parameter sets the dimension of the output array to 2-D or 3-D for frame-based inputs. The block ignores this parameter for 1-D and sample-based inputs. The Frames parameter has the following two settings:
Log frames separately (3-D array): Given an M-by-N frame-based input signal, the block outputs an M-by-N-by-K array, where K is the number of frames logged by the end of the simulation. (K is bounded above by the Limit data points to last parameter.) Each input frame is an element of the 3-D array. (See Example 2: Frame-Based Inputs.)
Concatenate frames (2-D array): Given an M-by-N frame-based input signal with frame size f, the block outputs a (K*f)-by-N matrix, where K*f is the number of samples acquired by the end of the simulation. Each input frame is vertically concatenated to the previous frame to produce the 2-D array output. (See Example 2: Frame-Based Inputs.)
Signal to Workspace always logs sample-based input data as 3-D arrays, regardless of the Frame parameter setting. Given an M-by-N sample-based signal, the block outputs an M-by-N-by-L array, where L is the number of samples logged by the end of the simulation (L is bounded above by the Limit data points to last parameter). Each sample-based matrix is an element of the 3-D array. (See Example 1: Sample-Based Inputs.)
For 1-D vector inputs, the block outputs a 2-D matrix regardless of the setting of Frame. For a length-N 1-D vector input, the block outputs an L-by-N matrix. Each input vector is a row of the output matrix, vertically concatenated to the previous vector.
The following table summarizes the output array dimensions for various block inputs. In the table, f is the frame size of the input, K is the number of frames acquired by the end of the simulation, and L is the number of samples acquired by the end of the simulation (K and L are bounded above by the Limit data points to last parameter).
| Input Signal Type | Signal To Workspace Output Dimension |
|---|---|
Sample-based M-by-N matrix | M-by-N-by-L array |
Length-N 1-D vector | L-by-N matrix |
Frame-based M-by-N matrix; Frame set to Log frames separately (3-D array) | M-by-N-by-K array |
Frame-based M-by-N matrix; Frame set to Concatenate frames (2-D array) | (K*f)-by-N matrix K*f is the number of samples acquired by the end of the simulation. |
The To Workspace block in the Simulink Sinks Library and the Signal To Workspace block can output the same array when they are given the same inputs. To match the blocks' outputs, set their parameters as follows.
| Block Parameters | Signal To Workspace | To Workspace |
|---|---|---|
Limit data points to last | x (any positive integer or inf) | x |
Decimation | y (any positive integer, not inf) | y |
Sample Time | No such parameter | -1 |
Save format | No such parameter | Array |
Frames | Concatenate frames (2-D array) | No such parameter |
In the following model, the input to the Signal To Workspace block is a 2-by-2 sample-based matrix signal with a sample time of 1 (generated by a Signal From Workspace block). The Signal To Workspace block logs 11 samples by the end of the simulation, and creates a 2-by-2-by-11 array, A, in the MATLAB workspace.

The block settings are as follows.
| Signal To Workspace Block Parameters | |
|---|---|
Variable name | yout |
Limit data points to last | inf |
Decimation | 1 |
Frames | Ignored since block input is not frame based |
| Configuration Dialog Box Parameters | |
Start time | 0 |
Stop time | 10 |
| Signal From Workspace Parameters (provides Signal To Workspace input) | |
Signal | input1 (defined below) |
Sample time | 1 |
Samples per frame | 1 |
Form output after final data value by | Setting to zero |
input1 = cat(3, [1 1; -1 0], [2 1; -2 0],...,[11 1; -11 0])
In the following model, the input to the Signal To Workspace block is a 2-by-4 frame-based matrix signal with a frame period of 1 (generated by a Signal From Workspace block). The block logs 11 frames (two samples per frame) by the end of the simulation. The frames are concatenated to create a 22-by-4 matrix, A, in the MATLAB workspace.
The block settings for the following model are similar to the settings used in Example 1, except Frames is set to Concatenate frames (2-D array) and the Signal From Workspace parameter, Signal, is set to input2, where
input2 = [1 -1 1 0; 2 -2 1 0; 3 -3 1 0;...; 22 -22 1 0]

In the 2-D output, there is no indication of where one frame ends and another begins. By setting Frames to Log frames separately (3-D array) in this model, you can easily see each frame in the MATLAB workspace, as illustrated in the following model. Each of the 11 frames is logged separately to create a 2-by-4-by-11 array, A, in the MATLAB workspace.


The name of the array that holds the input data.
The maximum number of input samples (for sample-based inputs) or input frames (for frame-based inputs) to be saved.
The decimation factor, d. Data is written at every dth sample.
The output dimensionality for frame-based inputs. Frames can be set to Concatenate frames (2-D array) or Log frames separately (3-D array). This parameter is ignored when inputs are not frame based.
Select to log fixed-point data to the MATLAB workspace as a Fixed-Point Toolbox fi object. Otherwise, fixed-point data is logged to the workspace as double.
Double-precision floating point
Single-precision floating point
Fixed point (signed and unsigned)
8-, 16-, and 32-bit signed integers
8-, 16-, and 32-bit unsigned integers
| Triggered To Workspace | Signal Processing Blockset |
| To Workspace | Simulink |
![]() | Signal From Workspace | Sine Wave | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |