This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

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.

dsp.SignalSource System object

Import variable from workspace


The SignalSource object imports a variable from the MATLAB® workspace.

To import a variable from the MATLAB workspace:

  1. Define and set up your signal source. See Construction.

  2. Call step to import the variable according to the properties of dsp.SignalSource. The behavior of step is specific to each object in the toolbox.


Starting in R2016b, instead of using the step method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, y = step(obj) and y = obj() perform equivalent operations.


src = dsp.SignalSource returns a signal source System object, src, that outputs the variable one sample or frame at a time.

src = dsp.SignalSource('PropertyName',PropertyValue,...) returns a signal source object, src, with each specified property set to the specified value.

src = dsp.SignalSource(signal,spf,'PropertyName',PropertyValue,...) returns a signal source object, src, with the Signal property set to signal, the SamplesPerFrame property set to spf, and other specified properties set to the specified values.



Variable or expression containing the signal

Specify the name of the workspace variable from which to import the signal, or a valid expression specifying the signal. The default is [1:10].


Number of samples per output frame

Specify the number of samples to buffer into each output frame. This property must be 1 when you specify a 3-D array in the Signal property. The default is 1.


Action after final signal values are generated

Specify the output after all of the specified signal samples have been generated as one of Set to zero, Hold final value, or Cyclic repetition. The default is Set to zero.


isDoneEnd-of-file status for signal reader object
resetReset internal states of signal reader object
stepRead one sample or frame of signal
Common to All System Objects

Allow System object property value changes


expand all

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;
    y1(idx) = src1();
    idx = idx+1;

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 object does not have properties that correspond to the Sample time or Warn when frame size does not evenly divide input length block parameters.

Extended Capabilities

Introduced in R2012b