Import variable from workspace
SignalSource object imports a variable from the
To import a variable from the MATLAB workspace:
dsp.SignalSource object and set its properties.
Call the object with arguments, as if it were a function.
To learn more about how System objects work, see What Are System Objects? (MATLAB).
returns a signal
src = dsp.SignalSource
src, that outputs the variable, specified
Signal property, one sample or frame at a time.
returns a signal source object,
src = dsp.SignalSource(
src, with the
Signal property set to
signal and the SamplesPerFrame property set to
src = dsp.SignalSource( returns a
signal source object,
src, with each specified property set to the
Unless otherwise indicated, properties are nontunable, which means you cannot change their
values after calling the object. Objects lock when you call them, and the
release function unlocks them.
If a property is tunable, you can change its value at any time.
For more information on changing property values, see System Design in MATLAB Using System Objects (MATLAB).
Signal— Variable or expression containing the signal
[1:10]'(default) | vector | matrix
Specify the name of the workspace variable from which to import the signal, or a valid expression specifying the signal.
Complex Number Support: Yes
SamplesPerFrame— Number of samples per output frame
1(default) | positive scalar
Specify the number of samples to buffer into each output frame. This property must
1 when you specify a 3-D array in the
SignalEndAction— Action after final signal values are generated
'Set to zero'(default) |
'Hold final value'|
Specify the output after all of the specified signal samples have been generated as
'Set to zero',
'Hold final value', or
Y— Output data
One sample or one frame of data from each column of the imported signal, returned
as a scalar, vector, or matrix. The number of columns in the output signal matches the
number of columns in the imported signal,
Signal. The number of
rows in the output signal matches the value specified in the
Complex Number Support: Yes
To use an object function, specify the
object as the first input argument. For
example, to release system resources of a System
Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent
step syntax. For example, myObject() becomes step(myObject).
Create a signal source to output one sample at a time.
src1 = dsp.SignalSource; src1.Signal = randn(1024,1); y1 = zeros(1024,1); idx = 1; while(~isDone(src1)) y1(idx) = src1(); idx = idx + 1; end
Create a signal source to output vectors.
src2 = dsp.SignalSource(randn(1024,1),128); y2 = src2(); % y2 is a 128-by-1 frame of samples
This object implements the algorithm, inputs, and outputs described on the Signal From Workspace block reference page. The object properties correspond to the block parameters, except the System object does not have properties that correspond to the Sample time or Warn when frame size does not evenly divide input length block parameters.
Usage notes and limitations:
See System Objects in MATLAB Code Generation (MATLAB Coder).