# Documentation

### This is machine translation

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

## What Are System Objects?

A System object™ is a specialized kind of MATLAB® object. System Toolboxes include System objects and most System Toolboxes also have MATLAB functions and Simulink® blocks. System objects are designed specifically for implementing and simulating dynamic systems with inputs that change over time. Many signal processing, communications, and controls systems are dynamic. In a dynamic system, the values of the output signals depend on both the instantaneous values of the input signals and on the past behavior of the system. System objects use internal states to store that past behavior, which is used in the next computational step. As a result, System objects are optimized for iterative computations that process large streams of data in segments, such as video and audio processing systems. This ability to process streaming data provides the advantage of not having to hold large amounts of data in memory. Use of streaming data also allows you to use simplified programs that use loops efficiently.

For example, you could use System objects in a system that reads data from a file, filters that data and then writes the filtered output to another file. Typically, a specified amount of data is passed to the filter in each loop iteration. The file reader object uses a state to keep track of where in the file to begin the next data read. Likewise, the file writer object keeps tracks of where it last wrote data to the output file so that data is not overwritten. The filter object maintains its own internal states to ensure that the filtering is performed correctly. This diagram represents a single loop of the system.

These advantages make System objects particularly well suited for processing streaming data.

Many System objects support:

• Fixed-point arithmetic (requires a Fixed-Point Designer™ license)

• C code generation (requires a MATLAB Coder™ or Simulink Coder license)

• HDL code generation (requires an HDL Coder™ license)

• Executable files or shared libraries generation (requires a MATLAB Compiler™ license)

 Note:   Check your product documentation to confirm fixed-point, code generation, and MATLAB Compiler support for the specific System objects you want to use.

System objects use a minimum of two commands to process data—a constructor to create the object (such as, fft256 = dsp.FFT) and a function call (such as, fft256(x)) to run data through the object. This separation of declaration from execution lets you create multiple, persistent, reusable objects, each with different settings. Using this approach avoids repeated input validation and verification, allows for easy use within a programming loop, and improves overall performance. In contrast, MATLAB functions must validate parameters every time you call the function.

In addition to the System objects provided with System Toolboxes, you can also create your own System objects. See Create System Objects.

### Running a System Object

To run a System object and perform the operation defined by its algorithm, you call the object as if it were a function. For example, to create an FFT object that uses the dsp.FFT System object, specifies a length of 1024, and names it dft, use

dft = dsp.FFT; 
To run this object on input x, use
dft(x);
If you run a System object without any input arguments, you must include empty parentheses. For example, asysobj().

When you run a System object, it also performs other important tasks related to data processing, such as initialization and handling object states.

 Note:   An alternative way to run a System object is to use the step method. For example, for an object created using dft = dsp.FFT, you can run it using step(dft,x).

#### Calculate Propagation of Signal in Free Space

This example how to use two different step methods. The first step method is associated with the phased.LinearFMWaveform (Phased Array System Toolbox) System object™. The second step method is associated with the phased.FreeSpace (Phased Array System Toolbox) System object™.

Construct a linear FM waveform with a pulse duration of 50 microseconds, a sweep bandwidth of 100 kHz, an increasing instantaneous frequency, and a pulse repetition frequency (PRF) of 10 kHz.

sLFM = phased.LinearFMWaveform('SampleRate',1e6,... 'PulseWidth',5e-5,'PRF',1e4,... 'SweepBandwidth',1e5,'SweepDirection','Up',... 'OutputFormat','Pulses','NumPulses',1); 

Obtain the transmitted waveform.

sig = sLFM(); 

Construct a phased.Freespace System object™ having a propagation speed equal to the speed of light, an operating frequency of 3 GHz, and a sample rate of 1 MHz. The Freespace object models one-way propagation. Then, propagate the transmitted signal from coordinates (0,0,0) to (500,1000,20) meters.

sFS = phased.FreeSpace(... 'PropagationSpeed',physconst('LightSpeed'),... 'OperatingFrequency',3e9,'TwoWayPropagation',false,... 'SampleRate',1e6); propsig = sFS(sig,[0; 0; 0],[500; 1e3; 20],... [0;0;0],[0;0;0]); 

Plot the real part of the transmitted signal and the real part of the propagated signal for comparison.

t = 1000000*unigrid(0,1/sFS.SampleRate,length(sig)*1/sFS.SampleRate,'[)'); subplot(211) plot(t,real(sig)) title('Original Signal (real part)') ylabel('Amplitude') subplot(212) plot(t,real(propsig)) title('Propagated Signal (real part)') xlabel('Time (\mu sec)') ylabel('Amplitude') 

### System Object Methods

After you create a System object, you use various object methods to process data or obtain information from or about the object. The syntax for using methods is <method>(<system object name>), plus possible extra input arguments. For example, for txfourier = dsp.FFT, where txfourier is a name you assign, you call the reset method using reset(txfourier). For more information about methods, see the descriptions in Common Methods.

#### Common Methods

All System objects support the following methods, each of which is linked from each object's reference page. In cases where a method is not applicable to a particular object, calling that method has no effect on the object.

MethodDescription
Run System object like a function, or
step

Run the object to process data using the algorithm defined by that object.

Example: For dft = dsp.FFT;, the standard way to run the object is y = dft(x). The alternative way is y = step(dft,x).

As part of this processing, the object initializes needed resources, returns outputs, and updates the object states. After you start running the object, you cannot change any input specifications (i.e., dimensions, data type, complexity). During execution, you can change only tunable properties. Both ways of running a System object return regular MATLAB variables.

release

Releases any special resources allocated by the object, such as file handles and device drivers, and unlocks the object. For System objects, use the release method instead of a destructor.

resetResets the internal states of a locked object to the initial values for that object and leaves the object locked
getNumInputsReturns the number of inputs (excluding the object itself) expected running the object. This number varies for an object depending on whether any properties enable additional inputs.
getNumOutputsReturns the number of outputs expected from running the object. This number varies for an object depending on whether any properties enable additional outputs.
getDiscreteStateReturns the discrete states of the object in a structure. If the object is unlocked (when the object is first created and before you have run it or after you have released the object), the states are empty. If the object has no discrete states, getDiscreteState returns an empty structure.
cloneCreates another object of the same type with the same property values
isLockedReturns a logical value indicating whether the object is locked.
isDoneApplies to source objects only. Returns a logical value indicating whether the end of the data file has been reached. If a particular object does not have end-of-data capability, this method value returns false.
infoReturns a structure containing characteristic information about the object. The fields of this structure vary depending on the object. If a particular object does not have characteristic information, the structure is empty.