This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

dsp.SignalSource System object

Package: dsp

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.

    Note:   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.


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

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

H = dsp.SignalSource(signal,spf,'PropertyName',PropertyValue,...) returns a signal source object, H, 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.


cloneCreate signal reader object with same property values
isDoneEnd-of-file status for signal reader object
isLockedLocked status for input attributes and nontunable properties
releaseAllow property value and input characteristics changes
resetReset internal states of signal reader object
stepRead one sample or frame of signal


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.

hsr1 = dsp.SignalSource;
hsr1.Signal = randn(1024, 1);
y1 = zeros(1024,1);
idx = 1;
    y1(idx) = hsr1();
    idx = idx+1;

Create a signal source to output vectors.

hsr2 = dsp.SignalSource(randn(1024, 1), 128);
y2 = hsr2(); % 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.

Introduced in R2012b

Was this topic helpful?