Signal From Workspace
Import signal from MATLAB workspace
Libraries:
DSP System Toolbox /
Sources
Description
The Signal From Workspace block imports a signal from the MATLAB® workspace into the Simulink® model. The Signal parameter specifies the name of a MATLAB workspace variable containing the signal to import, or any valid MATLAB expression defining a matrix or 3-D array.
Unlike the Simulink From Workspace (Simulink) block, the Signal From Workspace block holds the output value constant between successive output frames (that is, no linear interpolation takes place). Also, the initial signal values are always produced immediately at t=0.
Examples
Import Two-Channel Signal From Workspace
Import a two-channel signal, A
, from the MATLAB® workspace into the Simulink® model using the Signal From Workspace block. Use the To Workspace block to write the imported data to the MATLAB workspace. In this model, the To Workspace block writes slightly modified data to the MATLAB workspace.
The parameters in the Signal From Workspace block are configured as follows:
Sample time set to
1
: This parameter determines, Ts , the sample period of the output.Samples per frame set to
4
: Number of samples, Mo , to buffer into each output frame. The output frame period is MoTs.Form output after final value by set to
Setting to zero
: The block generates zero-valued outputs for the duration of the simulation after generating the last frame of the signal.
Open and simulate the ex_signal_from_workspace_frames.slx
model.
The Signal From Workspace block imports the signal from the variable A, which is a 10-by-2 matrix. When you simulate the model, the data output has a frame size of 4 and a frame period, MoTs , of 4 seconds. All outputs after the third frame (at t = 8
) are zero because the Form output after final data value by parameter is set to Setting to zero
in this model. The To Workspace block writes this modified output to the variable dsp_ex_yout
in the MATLAB workspace.
This figure shows the signal in the input variable A
and how this data is written to the output array dsp_ex_yout
.
Import 3-D Array From Workspace
Import a 3-D array A
from the MATLAB® workspace into the Simulink® model using the Signal From Workspace block. Use the To Workspace block to write the imported data to the MATLAB workspace. In this model, the To Workspace block slightly modifies data.
The parameters in the Signal From Workspace block are configured as follows:
Sample time set to
1
: This parameter determines, Ts , the sample period of the output.Samples per frame set to
1
: Number of samples, Mo , to buffer into each output frame. The output frame period is MoTs.Form output after final data value by set to
Setting to zero
: The block generates zero-valued outputs for the duration of the simulation after generating the last frame of the signal.
Open and simulate the ex_signal_from_workspace_3d.slx
model.
The Signal From Workspace block imports the signal from the variable A
, which is a 2-by-2-by-3 array. When you simulate the model, each of the three pages (a 2-by-2 matrix) is output in sequence with period Ts. The third page is a matrix of zeros because the Form output after final data value by parameter is set to Setting to zero
in this model. The To Workspace block writes the sequence of these matrices to the MATLAB workspace in the variable dsp_ex_yout
.
This figure shows the signal in the input variable A
and how this data is written to the output array dsp_ex_yout
.
Ports
Output
Port_1 — Signal imported from workspace
scalar | vector | matrix | 3-D array
Signal imported from workspace, as a scalar, vector, matrix, or 3-D array.
When the Signal parameter specifies an M-by-N matrix (M≠1), each of the N columns is treated as a distinct channel. You specify the frame size in the Samples per frame parameter, Mo. The output is an Mo-by-N matrix containing Mo consecutive samples from each signal channel. You specify the output sample period in the Sample time parameter, Ts, and the output frame period is MoTs. For convenience, an imported row vector (M=1) is treated as a single channel, so the output dimension is Mo-by-1.
When the Signal parameter specifies an
M-by-N-by-P
array, each of the P pages (an
M-by-N matrix) is output in
sequence with period Ts. The
Samples per frame parameter must be set to
1
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fixed point
Parameters
Signal — Signal to import
1:10
(default) | MATLAB workspace variable | MATLAB expression
The name of the MATLAB workspace variable from which to import the signal, or a valid MATLAB expression specifying the signal.
Sample time — Output sample period
1
(default) | scalar
The sample period, Ts, of the output, specified as a scalar. The output frame period is MoTs.
Samples per frame — Samples per frame
1
(default) | positive integer
The number of samples, Mo, to
buffer into each output frame, specified as a positive integer scalar. This
value must be 1
when you specify a 3-D array in the
Signal parameter.
Form output after final data value by — Values to output after final imported signal value
Setting to zero
(default) | Holding final value
| Cyclic repetition
Specifies the output after all of the specified signal samples have been generated.
When you specify
Setting To Zero
, the block generates zero-valued outputs for the duration of the simulation after generating the last frame of the signal.When you specify
Holding Final Value
, the block repeats the final sample for the duration of the simulation after generating the last frame of the signal.When you specify
Cyclic Repetition
, the block repeats the signal from the beginning after it reaches the last sample in the signal. If the frame size you specify in the Samples per frame parameter does not evenly divide the input length, a buffer block is inserted into the Signal From Workspace subsystem, and the model becomes multirate. If you do not want your model to become multirate, make sure that the frame size evenly divides the input signal length.
The block does not extrapolate the imported signal beyond the last sample.
Warn when frame size does not evenly divide input length — Warn when input length is not an integer multiple of frame size
off
(default) | on
Select the Warn when frame size does not evenly divide input length parameter to be alerted when the input length is not an integer multiple of the frame size. When the input length is not an integer multiple of the frame size, the model becomes multirate. Use the Model Explorer to turn these warnings on or off model-wide:
In the Modeling tab, click Model Explorer.
In the Search bar of the Model Explorer, search
by Property Name
for theignoreOrWarnInputAndFrameLengths
property. Each block with the Warn when frame size does not evenly divide input length check box appears in the list in the Contents pane.Select each of the blocks for which you want to toggle the warning parameter, and select or clear the check box in the
ignoreOrWarnInputAndFrameLengths
column.
Dependencies
To enable this parameter set Form output after final data
value by to Cyclic
Repetition
.
Block Characteristics
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Version History
Introduced before R2006a
See Also
Blocks
- Signal To Workspace | From Workspace (Simulink) | To Workspace (Simulink) | Triggered Signal From Workspace
Objects
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)