Main Content

dsp.SignalSource

Import variable from workspace

Description

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?

Creation

Description

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.

example

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.

example

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

Properties

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.

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

Usage

Syntax

Description

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.

example

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:

release(obj)

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

Examples

collapse all

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

Algorithms

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

Version History

Introduced in R2012b

See Also

Functions

Objects