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.


Import variable from workspace


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

To import a variable from the MATLAB workspace:

  1. Create the dsp.SignalSource object and set its properties.

  2. 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).



src = dsp.SignalSource
src = dsp.SignalSource(signal,spf)
src = dsp.SignalSource(Name,Value)



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


src = dsp.SignalSource(signal,spf) returns a signal source object, src, with the Signal property set to signal and the SamplesPerFrame property set to spf.

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


expand all

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).

Specify the name of the workspace variable from which to import the signal, or a valid expression specifying the signal.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | fi
Complex Number Support: Yes

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.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

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'.


For versions earlier than R2016b, use the step function to run the System object algorithm. The arguments to step are the object you created, followed by the arguments shown in this section.

For example, y = step(obj,x) and y = obj(x) perform equivalent operations.


Y = src()



Y = src() outputs one sample or frame of data from each column of the imported signal. The imported signal is the variable or expression you specify for the Signal property of the SignalSource System object, src.

Output Arguments

expand all

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 SamplesPerFrame property.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | fi
Complex Number Support: Yes

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:


expand all

isDoneEnd-of-file status for signal reader object
stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object


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

Extended Capabilities

See Also


System Objects

Introduced in R2012b