DSP Blockset    
Signal To Workspace

Write simulation data to an array in the MATLAB main workspace.

Library

DSP Sinks

Description

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 if their parameters are set appropriately.

For more information on the Signal To Workspace block, see the following sections of this reference page:

Parameter Descriptions

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. If 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. If the block input is frame-based, this parameter indicates how many frames of data to save. If 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:

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.

Output Dimension Summary

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.

Matching the Outputs of Signal To Workspace and To Workspace Blocks

The To Workspace block in the Simulink Sinks Library and the Signal To Workspace block can output the same array if 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

Examples

Example 1: Sample-Based Inputs.   In the following Example 1 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 Example 1 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
                     
Simulation Parameters Dialog 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

Example 2: Frame-Based Inputs.   In the following Example 2 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 Example 2 model are similar to the Example 1 block settings, except Frames is set to Concatenate frames (2-D array) and the Signal From Workspace parameter, Signal, is set to input2, where

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 the Example 2 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.

Dialog Box

Variable name
The name of the array that holds the input data. Tunable.
Limit data points to last
The maximum number of input samples (for sample-based inputs) or input frames (for frame-based inputs) to be saved. Tunable.
Decimation
The decimation factor, d. Data is written at every dth sample. Tunable.
Frames
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. Tunable.

Supported Data Types

To learn how to convert to the above data types in MATLAB and Simulink, see Supported Data Types and How to Convert to Them.

See Also

Triggered To Workspace
DSP Blockset
To Workspace
Simulink

Also see DSP Sinks for a list of all the blocks in the DSP Sinks library.


  Signal From Workspace Sine Wave