# spectrumAnalyzer

Display frequency spectrum of time-domain signals

## Description

The `spectrumAnalyzer`

object displays frequency-domain signals and
the frequency spectrum of time-domain signals. The scope shows the spectrum view and the
spectrogram view. The object performs spectral estimation using the filter bank method and
Welch's method of averaged modified periodograms. You can customize the spectrum analyzer
display to show the data and the measurement information that you need. For more details, see
Algorithms.

To display the spectra of signals in the Spectrum Analyzer:

Create the

`spectrumAnalyzer`

object and set its properties.Call the object with arguments, as if it were a function.

## Creation

### Description

`scope = spectrumAnalyzer`

creates a
`spectrumAnalyzer`

object that displays the frequency spectrum of real or
complex signals.

`scope = spectrumAnalyzer(Name=Value)`

specifies nondefault
properties for `scope`

using one or more name-value arguments. For example,
to display both spectrum and spectrogram, set `ViewType`

to
`"spectrum-and-spectrogram"`

.

## Properties

### Frequently Used

`InputDomain`

— Domain of input signal

`"time"`

(default) | `"frequency"`

The domain of the input signal you want to visualize, specified as
`"time"`

or `"frequency"`

. If you want to
visualize time-domain signals, the Spectrum Analyzer transforms the signal to the
frequency spectrum based on the algorithm you specify in the `Method`

property.

#### Scope Window Use

In the **Estimation** tab on the Spectrum Analyzer toolstrip,
set **Input Domain** to `Time`

or
`Frequency`

.

**Data Types: **`char`

| `string`

`SpectrumType`

— Type of spectrum to display

`"power"`

(default) | `"power-density"`

| `"rms"`

The type of spectrum to display, specified as one of the following:

`"power"`

— Power spectrum.`"power-density"`

— Power spectral density. The power spectral density is the squared magnitude of the spectrum normalized to a bandwidth of 1 hertz.`"rms"`

— Root mean square. The root-mean-square shows the square root of the mean square. Use this option to view the frequency of voltage or current signals.

**Tunable: **Yes

#### Dependency

To enable this property, set `InputDomain`

to `"time"`

.

#### Scope Window Use

In the **Analyzer** tab on the Spectrum Analyzer toolstrip,
click the drop down arrow of **Spectrum** to select
`Power`

, `Power Density`

, or
`RMS`

.

To enable these options, set the **Input Domain** on the
**Estimation** tab to `Time`

.

**Data Types: **`char`

| `string`

`ViewType`

— View to display

`"spectrum"`

(default) | `"spectrogram"`

| `"spectrum-and-spectrogram"`

View to display, specified as one of the following:

`"spectrum"`

— Display frequency spectrum of signals.`"spectrogram"`

— Display spectrogram of signals. Spectrogram shows the frequency content over time. Each line of the spectrogram is one periodogram. Time scrolls from the top to the bottom of the display. The most recent spectrogram update is at the top of the display.`"spectrum-and-spectrogram"`

— Display both spectrum and spectrogram.

To learn more about spectrum and spectrogram, see Periodogram and Spectrogram.

**Tunable: **Yes

#### Scope Window Use

In the **Analyzer** tab on the Spectrum Analyzer toolstrip,
select **Spectrum**, **Spectrogram**, or
both.

**Data Types: **`char`

| `string`

`SampleRate`

— Sample rate of input

`10000`

(default) | finite scalar

The sample rate of the input in Hz, specified as a finite scalar.

#### Scope Window Use

Click the **Analyzer** tab on the Spectrum Analyzer toolstrip.
In the **Bandwidth** section, specify **Sample Rate
(Hz)** to a finite scalar.

You can enable this property in the status bar at the bottom of the Spectrum
Analyzer window. Right-click the status bar and select ```
Sample
Rate
```

.

**Data Types: **`double`

`Method`

— Spectrum estimation method

`"filter-bank"`

(default) | `"welch"`

Spectrum estimation method, specified as one of the following:

`"filter-bank"`

–– Use an analysis filter bank to estimate the power spectrum. Compared to Welch's method, this method has a lower noise floor, better frequency resolution, and lower spectral leakage and requires fewer samples per update.`"welch"`

–– Use Welch's method of averaged modified periodograms.

For more details on these methods, see Algorithms.

**Tunable: **Yes

#### Dependency

To enable this property, set `InputDomain`

to `"time"`

.

#### Scope Window Use

In the **Estimation** tab of the Spectrum Analyzer toolstrip,
set **Method** to `Filter bank`

or
`Welch`

.

To enable this parameter, set **Input Domain** to
`Time`

in the **Estimation** tab.

**Data Types: **`char`

| `string`

`PlotAsTwoSidedSpectrum`

— Option to plot spectrum as two-sided

`true`

(default) | `false`

Option to plot spectrum as two-sided, specified as one of the following:

`true`

— Compute and plot two-sided spectral estimates. When the input signal is complex-valued, you must set this property to`true`

.`false`

— Compute and plot one-sided spectral estimates. If you set this property to`false`

, then the input signal must be real-valued.When you set this property to

`false`

, the Spectrum Analyzer uses power-folding. The*y*-axis values are twice the amplitude that they would be if you were to set this property to`true`

, except at`0`

and the Nyquist frequency. A one-sided power spectral density (PSD) contains the total power of the signal in the frequency interval from DC to half the Nyquist rate. For more information, see`pwelch`

.

#### Scope Window Use

Click the **Spectrum** tab or the
**Spectrogram** tab (if enabled) of the Spectrum Analyzer
toolstrip. In the **Trace Options** section, select
**Two-Sided Spectrum** to compute and plot two-sided spectral
estimates.

**Data Types: **`logical`

`FrequencyScale`

— Scale to display frequency

`"linear"`

(default) | `"log"`

Scale to display frequency, specified as one of the following:

`"linear"`

— Use a linear scale to display frequencies on the*x*-axis.`"log"`

— Use a logarithmic scale to display frequencies on the*x*-axis.

**Tunable: **Yes

#### Dependency

To set this property to `"log"`

, set the `PlotAsTwoSidedSpectrum`

property to `false`

.

#### Scope Window Use

Click the **Spectrum** tab or the
**Spectrogram** tab (if enabled) of the Spectrum Analyzer
toolstrip. In the **Scale** section, set the **Frequency
Scale** to `Linear`

or
`Log`

.

To set the **Frequency Scale** to
`Log`

, clear the **Two-Sided Spectrum**
check box in the **Trace Options** section in the
**Spectrum** or the **Spectrogram** tab (if
enabled). If you select the **Two-Sided Spectrum** check box, then
you must set the **Frequency Scale** to
`Linear`

.

**Data Types: **`char`

| `string`

`PlotType`

— Plot type for normal traces

`"line"`

(default) | `"stem"`

Type of plot to use for displaying normal traces, specified as
`"line"`

or `"stem"`

. Normal traces are traces
that display free-running spectral estimates.

**Tunable: **Yes

#### Dependencies

To enable this property, set:

`ViewType`

to`"spectrum"`

or`"spectrum-and-spectrogram"`

.`PlotNormalTrace`

to`true`

.

#### Scope Window Use

Click the **Analyzer** tab on the Spectrum Analyzer toolstrip,
navigate to the **Configuration** section and click
**Settings**. In the Spectrum Analyzer Settings window that
opens, under **Display and Labels**, set **Plot
Type** to `Line`

or
`Stem`

.

To enable the **Plot Type**, you must:

Either select

**Spectrum**or both**Spectrum**and**Spectrogram**in the**Views**section of the**Analyzer**tab.Enable the

**Normal Trace**check box in the**Trace Options**section of the**Spectrum**tab.

**Data Types: **`char`

| `string`

`AxesScaling`

— Axes scaling mode

`"auto"`

(default) | `"manual"`

| `"onceatstop"`

| `"updates"`

Axes scaling mode, specified as one of the following:

`"auto"`

— The scope scales the axes to fit the data, both during and after simulation.`"manual"`

— The scope does not scale the axes automatically.`"onceatstop"`

— The scope scales the axes when the simulation stops and you call the`release`

function.`"updates"`

— The scope scales the axes after a specific number of visual updates. It determines the number of updates using the`AxesScalingNumUpdates`

property.

**Tunable: **Yes

**Data Types: **`char`

| `string`

`AxesScalingNumUpdates`

— Number of updates before scaling

100 (default) | positive integer

Number of updates before scaling, specified as a positive integer.

**Tunable: **Yes

#### Dependency

To enable this property, set `AxesScaling`

to `"updates"`

.

**Data Types: **`double`

### Advanced

`RBWSource`

— Source of resolution bandwidth value

`"auto"`

(default) | `"property"`

The source of the resolution bandwidth (RBW), specified as
`"auto"`

or `"property"`

.

`"auto"`

— The Spectrum Analyzer adjusts the spectral estimation resolution to ensure that there are 1024 RBW intervals over the defined frequency span.`"property"`

— Specify the resolution bandwidth directly using the`RBW`

property.

**Tunable: **Yes

#### Scope Window Use

Click the **Analyzer** tab on the Spectrum Analyzer toolstrip.
In the **Bandwidth** section, set **RBW (Hz)**
to either `Auto`

or a positive scalar.

**Data Types: **`char`

| `string`

`RBW`

— Resolution bandwidth

`9.76`

(default) | positive scalar

Resolution bandwidth (RBW) in Hz, specified as a positive scalar. Specify the value to ensure at least two RBW intervals over the specified frequency span. The ratio of the overall span to RBW satisfies this condition:

$$\frac{span}{RBW}>2$$

Specify the overall span based on how you set the `FrequencySpan`

property.

RBW controls the spectral resolution of the displayed signal. The RBW value determines the spacing between frequencies that can be resolved. A smaller value gives a higher spectral resolution and lowers the noise floor. That is, the Spectrum Analyzer can resolve frequencies that are closer to each other. However, this comes at the cost of a longer sweep time.

For more details, see Resolution Bandwidth (RBW).

**Tunable: **Yes

#### Dependency

To enable this property, set `RBWSource`

to `"property"`

.

#### Scope Window Use

Click the **Analyzer** tab on the Spectrum Analyzer toolstrip.
In the **Bandwidth** section, set **RBW (Hz)**
to either `Auto`

or a positive scalar.

You can enable this property in the status bar at the bottom of the Spectrum
Analyzer window. Right-click the status bar and select
`RBW`

.

**Data Types: **`double`

`FrequencyVectorSource`

— Source of frequency vector

`"auto"`

(default) | `"property"`

Source of the frequency vector, specified as one of the following:

`"auto"`

— The Spectrum Analyzer computes the frequency vector based on the frame size of the input signal and the specified sample rate.`"property"`

— Enter a custom vector in the`FrequencyVector`

property.

**Tunable: **Yes

#### Dependency

To enable this property, set `InputDomain`

to `"frequency"`

.

#### Scope Window Use

Click the **Estimation** tab on the Spectrum Analyzer
toolstrip. In the **Domain** section, set **Frequency
(Hz)** to either `Auto`

or a monotonically
increasing vector of length equal to the input signal frame size.

To enable the **Frequency (Hz)**, set **Input
Domain** to `Frequency`

.

**Data Types: **`char`

| `string`

`FrequencyVector`

— Custom frequency vector

`[-5000 5000]`

(default) | monotonically increasing vector

Custom frequency vector, specified as a monotonically increasing vector. This
vector determines the *x*-axis of the display. The vector must be
monotonically increasing and must have the same length as the input signal frame
size.

**Tunable: **Yes

#### Dependency

To enable this property, set:

`InputDomain`

to`"frequency"`

.`FrequencyVectorSource`

to`"property"`

.

#### Scope Window Use

Click the **Estimation** tab on the Spectrum Analyzer
toolstrip. In the **Domain** section, set **Frequency
(Hz)** to either `Auto`

or a monotonically
increasing vector of length equal to the input signal frame size.

To enable the **Frequency (Hz)**, set **Input
Domain** to `Frequency`

.

**Data Types: **`double`

`FrequencySpan`

— Frequency span mode

`"full"`

(default) | `"span-and-center-frequency"`

| `"start-and-stop-frequencies"`

Frequency span mode, specified as one of the following:

`"full"`

–– The Spectrum Analyzer computes and plots the spectrum over the entire Nyquist Frequency Interval.`"span-and-center-frequency"`

–– The Spectrum Analyzer computes and plots the spectrum over the interval specified by the`Span`

and`CenterFrequency`

properties.`"start-and-stop-frequencies"`

–– The Spectrum Analyzer computes and plots the spectrum over the interval specified by the`StartFrequency`

and`StopFrequency`

properties.

**Tunable: **Yes

#### Dependency

To enable this property, set `InputDomain`

to `"time"`

.

#### Scope Window Use

Click the **Estimation** tab on the Spectrum Analyzer
toolstrip. In the **Frequency Options** section, set
**Frequency Span** to `Full`

,
`Span and Center Frequency`

, or ```
Start and
Stop Frequencies
```

.

To enable the **Frequency Span**, set **Input
Domain** to `Time`

.

**Data Types: **`char`

| `string`

`Span`

— Frequency span to compute spectrum

`10e3`

(default) | real positive scalar

Frequency span over which the Spectrum Analyzer computes and plots the spectrum,
specified as a positive scalar in Hz. The overall span, defined by this property and
the `CenterFrequency`

property, must fall within the Nyquist Frequency Interval.

**Tunable: **Yes

#### Dependency

To enable this property, set:

`InputDomain`

to`"time"`

`FrequencySpan`

to`"span-and-center-frequency"`

#### Scope Window Use

Click the **Estimation** tab on the Spectrum Analyzer
toolstrip. In the **Frequency Options** section, set
**Frequency Span** to ```
Span and Center
Frequency
```

and **Span (Hz)** to a positive
scalar.

To enable the **Frequency Span**, set **Input
Domain** to `Time`

.

**Data Types: **`double`

`CenterFrequency`

— Center of frequency span

`0`

(default) | real scalar

Center of frequency span over which the Spectrum Analyzer computes and plots the
spectrum, specified as a real scalar in Hz. The overall frequency span, defined by
`Span`

and this property, must fall within the Nyquist Frequency Interval.

**Tunable: **Yes

#### Dependency

To enable this property, set:

`InputDomain`

to`"time"`

`FrequencySpan`

to`"span-and-center-frequency"`

#### Scope Window Use

Click the **Estimation** tab on the Spectrum Analyzer
toolstrip. In the **Frequency Options** section, set
**Frequency Span** to ```
Span and Center
Frequency
```

and **Center Frequency (Hz)** to a real
scalar.

To enable the **Frequency Span**, set **Input
Domain** to `Time`

.

**Data Types: **`double`

`StartFrequency`

— Starting frequency in frequency interval

`-5e3`

(default) | real scalar

Starting frequency in the frequency interval over which the Spectrum Analyzer
computes and plots the spectrum, specified as a real scalar in Hz. The overall span,
which is defined by this property and `StopFrequency`

, must fall within the Nyquist Frequency Interval.

**Tunable: **Yes

#### Dependency

To enable this property, set:

`InputDomain`

to`"time"`

`FrequencySpan`

to`"start-and-stop-frequencies"`

#### Scope Window Use

Click the **Estimation** tab on the Spectrum Analyzer
toolstrip. In the **Frequency Options** section, set
**Frequency Span** to ```
Start and Stop
Frequencies
```

and **Start Frequency (Hz)** to a real
scalar.

To enable the **Frequency Span**, set **Input
Domain** to `Time`

.

**Data Types: **`double`

`StopFrequency`

— Ending frequency in frequency interval

`5e3`

(default) | real scalar

Ending frequency in the frequency interval over which the Spectrum Analyzer
computes and plots the spectrum, specified as a real scalar in Hz. The overall span,
which is defined by this property and the `StartFrequency`

property, must fall within the Nyquist Frequency Interval.

**Tunable: **Yes

#### Dependency

To enable this property, set:

`InputDomain`

to`"time"`

`FrequencySpan`

to`"start-and-stop-frequencies"`

#### Scope Window Use

Click the **Estimation** tab on the Spectrum Analyzer
toolstrip. In the **Frequency Options** section, set
**Frequency Span** to ```
Start and Stop
Frequencies
```

and **Stop Frequency (Hz)** to a real
scalar.

To enable the **Frequency Span**, set **Input
Domain** to `Time`

.

**Data Types: **`double`

`OverlapPercent`

— Percentage of overlap

`0`

(default) | scalar in the range [0 100)

Percentage of overlap between the previous and current buffered data segments, specified as a scalar in the range [0 100). The overlap creates a window segment that the object uses to compute a spectral estimate.

**Tunable: **Yes

#### Dependency

To enable this property, set:

`InputDomain`

to`"time"`

`Method`

to`"welch"`

#### Scope Window Use

Click the **Estimation** tab on the Spectrum Analyzer
toolstrip. In the **Window Options** section, set the
**Overlap (%)**.

To enable the **Overlap (%)**, set **Input
Domain** to `Time`

and
**Method** to `Welch`

in the
**Estimation** tab on the Spectrum Analyzer toolstrip.

**Data Types: **`double`

`Window`

— Window function

`"hann"`

(default) | `"blackman-harris"`

| `"chebyshev"`

| `"custom"`

| `"flat-top"`

| `"hamming"`

| `"kaiser"`

| `"rectangular"`

Window function, specified as one of the following preset windows. For more information on a window option, click the link to the corresponding function.

Window Option | Corresponding Signal Processing Toolbox™ Function |
---|---|

`"hann"` | `hann` |

`"blackman-harris"` | `blackmanharris` |

`"chebyshev"` | `chebwin` |

`"flat-top"` | `flattopwin` |

`"hamming"` | `hamming` |

`"kaiser"` | `kaiser` |

`"rectangular"` | `rectwin` |

To use your own spectral estimation window, set this property to
`"custom"`

and specify a custom window function in the `CustomWindow`

property.

**Tunable: **Yes

#### Dependency

To enable this property, set:

`InputDomain`

to`"time"`

`Method`

to`"welch"`

#### Scope Window Use

Click the **Estimation** tab on the Spectrum Analyzer
toolstrip. In the **Window Options** section, set the
**Window**.

To enable the **Window**, set **Input Domain**
to `Time`

and **Method** to
`Welch`

in the **Estimation** tab on the
Spectrum Analyzer toolstrip.

**Data Types: **`char`

| `string`

`CustomWindow`

— Name of custom window function

`"hann"`

(default) | character array | string scalar

Name of custom window function, specified as a character array or string scalar.
The custom window function name must be on the MATLAB^{®} path. Use this property to customize a window function using additional
properties available with the Signal Processing Toolbox.

**Tunable: **Yes

#### Example:

Define and use a custom window function.

function w = my_hann(L) w = hann(L,"periodic") end scope.Window = "custom"; scope.CustomWindow = "my_hann"

#### Dependency

To use this property, set `Window`

to `"custom"`

.

#### Scope Window Use

Click the **Estimation** tab on the Spectrum Analyzer
toolstrip. In the **Window Options** section, for the
**Window**, enter a custom window function name.

**Data Types: **`char`

| `string`

`SidelobeAttenuation`

— Sidelobe attenuation of window

`60`

(default) | positive scalar

Sidelobe attenuation of the window in decibels (dB), specified as a positive
scalar greater than or equal to `45`

.

**Tunable: **Yes

#### Dependency

To enable this property, set `Window`

to `"chebyshev"`

or
`"kaiser"`

.

#### Scope Window Use

Click the **Estimation** tab on the Spectrum Analyzer
toolstrip. In the **Window Options** section, set the
**Attenuation (dB)**.

To enable the **Attenuation (dB)**, set:

**Input Domain**to`Time`

**Method**to`Welch`

**Window**to either`Chebyshev`

or`Kaiser`

in the**Estimation**tab on the Spectrum Analyzer toolstrip.

**Data Types: **`double`

`AveragingMethod`

— Averaging method

`"vbw"`

(default) | `"exponential"`

Averaging method, specified as one of the following:

`"vbw"`

— Video bandwidth method. The object uses a lowpass filter to smooth the trace and decrease noise. Use the`VBWSource`

and`VBW`

properties to specify the VBW value.`"exponential"`

— Weighted average of samples. The object computes the average over samples weighted by an exponentially decaying forgetting factor. Use the`ForgettingFactor`

property to specify the weighted forgetting factor.

For more information on averaging methods, see Averaging Method.

**Tunable: **Yes

#### Dependency

To enable this property, set `InputDomain`

to `"time"`

.

#### Scope Window Use

Click the **Estimation** tab on the Spectrum Analyzer
toolstrip. In the **Averaging** section, set **Averaging
Method** to `VBW`

or
`Exponential`

.

To enable the **Averaging Method**, set **Input
Domain** to `Time`

.

**Data Types: **`char`

| `string`

`ForgettingFactor`

— Forgetting factor of weighted average method

`0.9`

(default) | scalar in the range [0,1]

Forgetting factor of the exponential weighted averaging method, specified as a scalar in the range [0,1].

**Tunable: **Yes

#### Dependency

To enable this property, set:

`InputDomain`

to`"time"`

.`AveragingMethod`

to`"exponential"`

#### Scope Window Use

Click the **Estimation** tab on the Spectrum Analyzer
toolstrip. In the **Averaging** section, adjust the slider for
**Forgetting Factor**.

To enable the **Forgetting Factor**, set **Input
Domain** to `Time`

and **Averaging
Method** to `Exponential`

.

**Data Types: **`double`

`VBWSource`

— Source of video bandwidth

`"auto"`

(default) | `"property"`

Source of the video bandwidth (VBW), specified as either `"auto"`

or `"property"`

.

`"auto"`

— The Spectrum Analyzer adjusts the VBW values to match the RBW values.`"property"`

— The Spectrum Analyzer adjusts the VBW using the value specified in the`VBW`

property.

**Tunable: **Yes

#### Dependency

To enable this property, set `InputDomain`

to `"time"`

and `AveragingMethod`

to `vbw`

.

#### Scope Window Use

Click the **Estimation** tab on the Spectrum Analyzer
toolstrip. In the **Averaging** section, set **VBW
(Hz)** to either `Auto`

or a positive real
scalar less than or equal to **Sample Rate (Hz)**/2.

To enable the **VBW (Hz)**, set **Input
Domain** to `Time`

and **Averaging
Method** to `VBW`

.

**Data Types: **`char`

| `string`

`VBW`

— Video bandwidth

`10`

(default) | positive scalar

Video bandwidth, specified as a positive scalar less than or equal to `SampleRate`

/2.

VBW is the bandwidth of a lowpass filter that is used to average or smooth the noise in the signal before it is displayed on the Spectrum Analyzer. Video bandwidth does not affect the level of the noise (noise floor), but only increases the signal-to-noise ratio and smoothes the trace of the noise.

When you decrease the value of VBW, the signal-to-noise ratio improves.

The cutoff frequency of the video bandwidth filter is given by:

$${\omega}_{c}=\frac{2\pi VBW}{{F}_{s}/NFFT}$$

where *Fs* is the input sample rate and NFFT is the number of FFT
points.

The Spectrum Analyzer shows the values of sample rate, VBW, and NFFT in the status
bar at the bottom of the display. To display the values, right-click the status bar
and select `Sample Rate`

, `VBW`

, and
`NFFT`

.

**Tunable: **Yes

#### Dependency

To enable this property, set `VBWSource`

to `"property"`

.

#### Scope Window Use

Click the **Estimation** tab on the Spectrum Analyzer
toolstrip. In the **Averaging** section, set **VBW
(Hz)** to either `Auto`

or enter a positive real
scalar that is less than or equal to **Sample Rate (Hz)**/2.

To enable the **VBW (Hz)**, set **Input
Domain** to `Time`

and **Averaging
Method** to `VBW`

.

**Data Types: **`double`

`InputUnits`

— Units of frequency input

`"dBm"`

(default) | `"dBV"`

| `"dBW"`

| `"Vrms"`

| `"Watts"`

| `"none"`

Units of the frequency-domain input, specified as `"dBm"`

,
`"dBV"`

, `"dBW"`

, `"Vrms"`

,
`"Watts"`

, or `"none"`

. The Spectrum Analyzer
scales frequency data according to the specified display unit.

**Tunable: **Yes

#### Dependency

To enable this property, set `InputDomain`

to `"frequency"`

.

#### Scope Window Use

Click the **Estimation** tab on the Spectrum Analyzer
toolstrip. In the **Domain** section, set **Input
Unit**.

To enable the **Input Unit**, set **Input
Domain** to `Frequency`

.

**Data Types: **`char`

| `string`

`SpectrumUnits`

— Units of the spectrum

`"dBm"`

(default) | `"dBFS"`

| `"dBV"`

| `"dBW"`

| `"Vrms"`

| `"Watts"`

| `"dBm/Hz"`

| `"dBW/Hz"`

| `"dBFS/Hz"`

| `"Watts/Hz"`

| `"auto"`

Units in which the Spectrum Analyzer displays power values, specified as one of the following:

`"dBm"`

`"dBFS"`

`"dBV"`

`"dBW"`

`"Vrms"`

`"Watts"`

`"dBm/Hz"`

`"dBW/Hz"`

`"dBFS/Hz"`

`"Watts/Hz"`

`"auto"`

**Tunable: **Yes

#### Dependency

The spectrum units available depend on the value you specify in the `SpectrumType`

property.

`InputDomain` | `SpectrumType` | Allowed `SpectrumUnits` |
---|---|---|

`"time"` | `"power"` | `"dBm"` , `"dBW"` ,
`"dBFS"` , `"Watts"` |

`"power-density"` | `"dBm/Hz"` ,
`"dBW/Hz"` ,`"dBFS/Hz"` ,
`"Watts/Hz"` | |

`"rms"` | `"dBV"` , `"Vrms"` | |

`"frequency"` | ― | `"auto"` , `"dBm"` ,
`"dBV"` , `"dBW"` ,
`"Vrms"` , `"Watts"` |

If you set the `InputDomain`

property to
`"frequency"`

and the `SpectrumUnits`

property
to `"auto"`

, the Spectrum Analyzer assumes the spectrum units to be
equal to input units specified in the `InputUnits`

property. If you set `InputDomain`

to
`"time"`

and `SpectrumUnits`

to any option
other than `"auto"`

, the Spectrum Analyzer converts the units
specified in `InputUnits`

to the units specified in
`SpectrumUnits`

.

#### Scope Window Use

Click the **Spectrum** tab on the Spectrum Analyzer toolstrip.
In the **Scale** section, set **Spectrum
Unit**.

**Data Types: **`char`

| `string`

`FullScaleSource`

— Source of full-scale value

`"auto"`

(default) | `"property"`

Source of the dBFS scaling factor, specified as either `"auto"`

or `"property"`

.

`"auto"`

–– The Spectrum Analyzer adjusts the scaling factor based on the input data.`"property"`

–– Specify the full-scale scaling factor using the`FullScale`

property.

**Tunable: **Yes

#### Dependency

To enable this property, set:

`InputDomain`

to`"time"`

`SpectrumType`

to`"power"`

or`"power-density"`

`SpectrumUnits`

to`"dBFS"`

#### Scope Window Use

Click the **Spectrum** tab on the Spectrum Analyzer toolstrip.
In the **Scale** section, set the **Full Scale**
to either `Auto`

or a positive scalar.

To enable the **Full Scale**:

In the

**Analyzer**tab, set the spectrum type to`Power`

or`Power Density`

.In the

**Estimation**tab, set**Input Domain**to`Time`

.In the

**Spectrum**tab, set**Spectrum Unit**to`dBFS`

or`dBFS/Hz`

(when spectrum type is set to`Power Density`

).

**Data Types: **`char`

| `string`

`FullScale`

— dBFS full scale

`1`

(default) | positive scalar

dBFS full scale, specified a positive scalar.

**Tunable: **Yes

#### Dependency

To enable this property, set:

`InputDomain`

to`"time"`

`SpectrumType`

to`"power"`

`SpectrumUnits`

to`"dBFS"`

`FullScaleSource`

to`"auto"`

#### Scope Window Use

Click the **Spectrum** tab on the Spectrum Analyzer toolstrip.
In the **Scale** section, set the **Full Scale**
to either `Auto`

or enter a positive scalar.

To enable the **Full Scale**:

In the

**Analyzer**tab, set the spectrum type to`Power`

.In the

**Estimation**tab, set**Input Domain**to`Time`

.In the

**Spectrum**tab, set**Spectrum Unit**to`dBFS`

.

**Data Types: **`double`

`ReferenceLoad`

— Reference load to compute power levels

`1`

(default) | positive scalar

Load that the scope uses as a reference to compute power levels, specified as a positive scalar in Ohms.

**Tunable: **Yes

#### Scope Window Use

Click the **Spectrum** tab on the Spectrum Analyzer toolstrip.
In the **Scale** section, set **Reference Load
(Ω)**.

**Data Types: **`double`

`FrequencyOffset`

— Offset to apply to frequency axis

`0`

(default) | scalar | vector

Offset to apply to the frequency axis (*x*-axis) in units of Hz,
specified as one of the following:

Scalar — Apply the same frequency offset to all channels.

Vector — Apply a specific frequency offset for each channel. The vector length must be equal to the number of input channels.

The overall span must fall within the Nyquist Frequency Interval. You can control the overall span in different ways based on how you set the FrequencySpan property.

**Tunable: **Yes

#### Scope Window Use

Click the **Analyzer** tab on the Spectrum Analyzer toolstrip.
In the **Bandwidth** section, set **Offset
(Hz)**.

**Data Types: **`double`

### Spectrogram

`SpectrogramChannel`

— Channel for which spectrogram is plotted

`1`

(default) | positive integer

Channel for which the spectrogram is plotted, specified as a positive integer in
the range [1 *N*], where *N* is the number of input
channels.

**Tunable: **Yes

#### Dependency

To enable this property, set `ViewType`

to `"spectrogram"`

or
`"spectrum-and-spectrogram"`

.

#### Scope Window Use

Click the **Spectrogram** tab on the Spectrum Analyzer
toolstrip. In the **Channel** section, select a
**Channel**.

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `uint8`

| `uint16`

| `uint32`

| `uint64`

`TimeResolutionSource`

— Source of the time resolution

`"auto"`

(default) | `"property"`

Source of the time resolution of each spectrogram line, specified as either
`"auto"`

or `"property"`

.

When you set `RBWSource`

and `TimeResolutionSource`

to
`"auto"`

, then RBW is set such that there are 1024 RBW intervals in
one frequency span. The time resolution is set to 1/`RBW`

.

When `RBWSource`

is set to `"auto"`

and
`TimeResolutionSource`

is set to `"property"`

,
then time resolution becomes the main control and RBW is set to 1/`TimeResolution`

Hz.

When `RBWSource`

is set to `"property"`

and
`TimeResolutionSource`

is set to `"auto"`

, then
RBW becomes the main control and the time resolution is set 1/RBW s.

When both `RBWSource`

and
`TimeResolutionSource`

are set to `"property"`

,
then the specified time resolution value must be equal to or larger than the minimum
attainable time resolution which is defined by 1/RBW. Several spectral estimates are
combined into one spectrogram line to obtain the desired time resolution.

**Tunable: **Yes

#### Dependency

To enable this property, set `ViewType`

to `"spectrogram"`

or
`"spectrum-and-spectrogram"`

.

#### Scope Window Use

Click the **Spectrogram** tab on the Spectrum Analyzer
toolstrip. In the **Time Options** section, set the **Time
Resolution (s)** to `Auto`

or enter a positive
scalar.

To enable the **Time Resolution (s)**, select
**Spectrogram** in the **Analyzer** tab.

**Data Types: **`char`

| `string`

`TimeResolution`

— Time resolution of each spectrogram line

`0.001`

(default) | positive scalar

Time resolution of each spectrogram line in seconds, specified as a positive scalar.

**Tunable: **Yes

#### Dependency

To enable this property, set:

`ViewType`

to`"spectrogram"`

or`"spectrum-and-spectrogram"`

`TimeResolutionSource`

to`"property`

.

#### Scope Window Use

Click the **Spectrogram** tab on the Spectrum Analyzer
toolstrip. In the **Time Options** section, set the **Time
Resolution (s)** to `Auto`

or enter a positive
scalar.

To enable the **Time Resolution (s)**, select
**Spectrogram** in the **Analyzer** tab.

**Data Types: **`double`

`TimeSpanSource`

— Source of time span value

`"auto"`

(default) | `"property"`

Source for the time span of the spectrogram,specified as either one of these:

`"auto"`

–– The spectrogram displays 100 spectrogram lines at any given time.`"property"`

–– The spectrogram uses the time duration you specify in seconds in the`TimeSpan`

property.The time span that you specify must be at least two times larger than the duration of the number of samples required for a spectral update.

**Tunable: **Yes

#### Dependency

To enable this property, set `ViewType`

to `"spectrogram"`

or
`"spectrum-and-spectrogram"`

.

#### Scope Window Use

Click the **Spectrogram** tab on the Spectrum Analyzer
toolstrip. In the **Time Options** section, set the **Time
Span (s)** to `Auto`

or enter a positive scalar.

**Data Types: **`char`

| `string`

`TimeSpan`

— Time span of spectrogram

`0.1`

(default) | positive scalar

Time span of the spectrogram display in seconds, specified as a positive scalar. You must set the time span to be at least twice as large as the duration of the number of samples required for a spectral update.

**Tunable: **Yes

#### Dependency

To enable this property, set:

`ViewType`

to`"spectrogram"`

or`"spectrum-and-spectrogram"`

.`TimeSpanSource`

to`"property"`

.

#### Scope Window Use

Click the **Spectrogram** tab on the Spectrum Analyzer
toolstrip. In the **Time Options** section, set the **Time
Span (s)** to `Auto`

or enter a positive scalar.

**Data Types: **`double`

### Measurements

`MeasurementChannel`

— Channel for which to obtain measurements

`1`

(default) | positive integer

The channel for which you need to obtain measurements, specified as a positive
integer in the range [1 *N*], where *N* is the
number of input channels.

**Tunable: **Yes

#### Scope Window Use

Click the **Measurements** tab on the Spectrum Analyzer
toolstrip. In the **Channel** section, select a
**Channel**.

**Data Types: **`double`

`ChannelMeasurements`

— Channel measurements

`ChannelMeasurementsConfiguration`

object

Channel measurements, specified as a `ChannelMeasurementsConfiguration`

object. Enable channel measurements to
compute and display the occupied bandwidth or adjacent channel power ratio. All
`ChannelMeasurementsConfiguration`

properties are tunable.

**Tunable: **Yes

#### Dependency

To enable this property, set `ViewType`

to either `"spectrum"`

or
`"spectrum-and-spectrogram"`

.

#### Scope Window Use

Click the **Channel Measurements** tab on the Spectrum Analyzer
toolstrip and modify the measurement settings.

The **Channel Measurements** tab appears when you select
**Spectrum** in the **Analyzer** tab.

`CursorMeasurements`

— Cursor measurements

`CursorMeasurementsConfiguration`

object

Cursor measurements, specified as a `CursorMeasurementsConfiguration`

object. Enable cursor measurements to
display screen or waveform cursors. All
`CursorMeasurementsConfiguration`

properties are tunable.

**Tunable: **Yes

#### Dependency

To enable this property, set `ViewType`

to either `"spectrum"`

or
`"spectrum-and-spectrogram"`

.

#### Scope Window Use

Click the **Measurements** tab on the Spectrum Analyzer
toolstrip and modify the cursor measurements in the **Cursors**
section.

The **Measurements** tab appears when you select
**Spectrum** in the **Analyzer** tab.

`DistortionMeasurements`

— Distortion measurements

`DistortionMeasurementsConfiguration`

object

Distortion measurements, specified as a `DistortionMeasurementsConfiguration`

object. Enable distortion measurements
to compute and display the harmonic distortion and intermodulation distortion. All
`DistortionMeasurementsConfiguration`

properties are tunable. For
more details, see Distortion Measurements and Harmonic Measurements.

**Tunable: **Yes

#### Dependency

To enable this property, set `ViewType`

to either `"spectrum"`

or
`"spectrum-and-spectrogram"`

.

#### Scope Window Use

Click the **Measurements** tab on the Spectrum Analyzer
toolstrip and modify the distortion measurements in the
**Distortion** section.

The **Measurements** tab appears when you select
**Spectrum** in the **Analyzer** tab.

`PeakFinder`

— Peak finder measurement

`PeakFinderConfiguration`

object

Peak finder measurement, specified as a `PeakFinderConfiguration`

object. Enable peak finder to compute and display
the largest calculated peak values. All `PeakFinderConfiguration`

properties are tunable.

**Tunable: **Yes

#### Dependency

To enable this property, set `ViewType`

to either `"spectrum"`

or
`"spectrum-and-spectrogram"`

.

#### Scope Window Use

Click the **Measurements** tab on the Spectrum Analyzer
toolstrip and modify the peak finder measurements in the **Peaks**
section.

The **Measurements** tab appears when you select
**Spectrum** in the **Analyzer** tab.

`SpectralMask`

— Spectral mask configuration

`SpectralMaskConfiguration`

object

Spectral mask configuration, specified as a `SpectralMaskConfiguration`

object. Use the spectral mask configuration to
draw upper and lower or upper or lower mask lines in the power and power-density
plots. All `SpectralMaskConfiguration`

properties are tunable.

**Tunable: **Yes

#### Dependency

To enable this property, set:

`ViewType`

to either`"spectrum"`

or`"spectrum-and-spectrogram"`

.`SpectrumType`

to either`"power"`

or`"power-density"`

.

#### Scope Window Use

Click the **Spectral Mask** tab on the Spectrum Analyzer
toolstrip and modify the settings.

The **Spectral Mask** tab appears when you:

Select

**Spectrum**in the**Analyzer**tab.In the drop-down list under

**Spectrum**, choose either`Power`

or`Power Density`

.

### Visualization

`Name`

— Caption to display on spectrum Analyzer window

`"Spectrum Analyzer"`

(default) | character vector | string scalar

Caption to display on the scope window, specified as a character vector or string.

**Tunable: **Yes

**Data Types: **`char`

| `string`

`Position`

— Spectrum Analyzer window position in pixels

`[left bottom 800 500]`

(default) | [`left bottom width height`

]

Spectrum Analyzer window position in pixels, specified as a four-element double
vector of the form [`left bottom width height`

]. You can place the
scope window in a specific position on your screen by modifying the values of this
property.

By default, the window appears at the center of your screen with a width of
`800`

pixels and height of `500`

pixels. The exact
center coordinates depend on your screen resolution.

**Tunable: **Yes

`MaximizeAxes`

— Maximize axes control

`"auto"`

(default) | `"on"`

| `"off"`

Maximize axes control, specified as one of the following:

`"auto"`

–– The Spectrum Analyzer maximizes axes only if the display does not contain any labels or title annotations.`"on"`

–– The Spectrum Analyzer maximizes axes in all displays.`"off"`

–– The Spectrum Analyzer does not maximize axes in any display.

**Tunable: **Yes

**Data Types: **`char`

| `string`

`PlotNormalTrace`

— Option to plot normal trace

`true`

(default) | `false`

To remove normal traces from the display, set this property to
`false`

. These traces display the free-running spectral estimates.
The Spectrum Analyzer continues its spectral computations even when you set this
property to `false`

.

**Tunable: **Yes

#### Dependency

To enable this property, set `ViewType`

to `"spectrum"`

or
`"spectrum-and-spectrogram"`

.

#### Scope Window Use

Click the **Spectrum** tab on the Spectrum Analyzer toolstrip
and select the **Normal Trace** check box in the **Trace
Options** section.

To enable the **Normal Trace** check box, select
**Spectrum** or **Spectrum** and
**Spectrogram** in the **Analyzer** tab.

**Data Types: **`logical`

`PlotMaxHoldTrace`

— Option to plot max-hold trace

`false`

(default) | `true`

Option to plot max-hold trace, specified as `true`

or
`false`

. To compute and plot the maximum-hold spectrum of each
input channel, set this property to `true`

. The Spectrum Analyzer
computes the maximum-hold spectrum at each frequency bin by keeping the maximum value
of all the power spectrum estimates. When you change the value of this property, the
Spectrum Analyzer resets its maximum-hold computations.

**Tunable: **Yes

#### Dependency

To enable this property, set `ViewType`

to `"spectrum"`

or
`"spectrum-and-spectrogram"`

.

#### Scope Window Use

Click the **Spectrum** tab on the Spectrum Analyzer toolstrip
and select the **Max-Hold Trace** check box in the **Trace
Options** section.

To enable the **Max-Hold Trace** check box, select
**Spectrum** or **Spectrum** and
**Spectrogram** in the **Analyzer** tab.

**Data Types: **`logical`

`PlotMinHoldTrace`

— Option to plot min-hold trace

`false`

(default) | `true`

Option to plot min-hold trace, specified as `true`

or
`false`

. To compute and plot the minimum-hold spectrum of each
input channel, set this property to `true`

. The Spectrum Analyzer
computes the minimum-hold spectrum at each frequency bin by keeping the minimum value
of all the power spectrum estimates. When you change the value of this property, the
Spectrum Analyzer resets its minimum-hold computations.

**Tunable: **Yes

#### Dependency

To enable this property, set `ViewType`

to `"spectrum"`

or
`"spectrum-and-spectrogram"`

.

#### Scope Window Use

Click the **Spectrum** tab on the Spectrum Analyzer toolstrip
and select the **Min-Hold Trace** check box in the **Trace
Options** section.

To enable the **Min-Hold Trace** check box, select
**Spectrum** or **Spectrum** and
**Spectrogram** in the **Analyzer** tab.

**Data Types: **`logical`

`Title`

— Display title

`''`

(default) | character vector | string scalar

Display title, specified as a character vector or a string scalar.

**Tunable: **Yes

#### Scope Window Use

Click the **Analyzer** tab on the Spectrum Analyzer toolstrip.
In the **Configuration** section, click
**Settings**. In the Spectrum Analyzer Settings window that
opens up, under **Display and labels**, enter
**Title**.

**Data Types: **`char`

| `string`

`YLabel`

— *y*-axis label

`''`

(default) | character vector | string scalar

*y*-axis label, specified as a character vector or a string
scalar. The Spectrum Analyzer displays the label to the left of the
*y*-axis.

Regardless of this property, Spectrum Analyzer always displays power units as one
of the `SpectrumUnits`

values.

**Tunable: **Yes

#### Dependency

To enable this property, set `ViewType`

to `"spectrum"`

or
`"spectrum-and-spectrogram"`

.

#### Scope Window Use

Click the **Analyzer** tab on the Spectrum Analyzer toolstrip.
In the **Configuration** section, click
**Settings**. In the Spectrum Analyzer Settings window that
opens up, under **Display and labels**, enter
**Y-Label**.

To enable the **Y-Label**, select **Spectrum**
or **Spectrum** and **Spectrogram** in the
**Analyzer** tab.

**Data Types: **`char`

| `string`

`YLimits`

— *y*-axis limits

`[-80, 20]`

(default) | [`ymin ymax`

]

*y*-axis limits, specified as a two-element numeric vector of the
form [`ymin ymax`

]. The units of the *y*-axis limits
depend on the `SpectrumUnits`

property.

**Example: **`scope.YLimits = [-10,20]`

**Tunable: **Yes

#### Dependencies

To enable this property, set the `ViewType`

property to `"spectrum"`

or
`"spectrum-and-spectrogram"`

.

#### Scope Window Use

Click the **Analyzer** tab on the Spectrum Analyzer toolstrip.
In the **Configuration** section, click
**Settings**. In the Spectrum Analyzer Settings window that
opens up, under **Display and Labels**, enter **Y-Axis
Limits**.

To enable the **Y-Axis Limits**, select
**Spectrum** or **Spectrum** and
**Spectrogram** in the **Analyzer** tab.

`ColorLimits`

— Color limits of spectrogram

`[-80, 20]`

(default) | `[colorMin colorMax]`

Color limits of the spectrogram, specified as a two-element numeric vector of the
form [`colorMin colorMax`

]. The units of the color limits directly
depend upon the `SpectrumUnits`

property.

**Example: **`scope.ColorLimits = [-10,20]`

**Tunable: **Yes

#### Dependencies

To enable this property, set the `ViewType`

property to `"spectrogram"`

or
`"spectrum-and-spectrogram"`

.

#### Scope Window Use

Click the **Analyzer** tab on the Spectrum Analyzer toolstrip.
In the **Configuration** section, click
**Settings**. In the Spectrum Analyzer Settings window that
opens up, under **Display and Labels**, enter **Color
Limits**.

To enable the **Color Limits**, select
**Spectrogram** or **Spectrum** and
**Spectrogram** in the **Analyzer** tab.

`Colormap`

— Color look-up table

`"jet"`

(default) | `"bone"`

| `"cool"`

| `"copper"`

| `"gray"`

| `"hot"`

| `"parula"`

| three-column matrix

Color look-up table, specified as a valid colormap name or a three-column matrix with values in the range [0,1] defining RGB triplets.

**Tunable: **Yes

#### Dependencies

To enable this property, set the `ViewType`

property to `"spectrogram"`

or
`"spectrum-and-spectrogram"`

.

#### Scope Window Use

Click the **Analyzer** tab on the Spectrum Analyzer toolstrip.
In the **Configuration** section, click
**Settings**. In the Spectrum Analyzer Settings window that
opens up, under **Display and Labels**, enter **Color
Map**.

To enable the **Color Map**, select
**Spectrogram** or **Spectrum** and
**Spectrogram** in the **Analyzer** tab.

**Data Types: **`double`

| `char`

| `string`

`ShowGrid`

— Show or hide grid

`true`

(default) | `false`

Show or hide the grid, specified as `true`

or
`false`

. Set this property to `true`

to show grid
lines in the plot.

**Tunable: **Yes

#### Scope Window Use

Click the **Analyzer** tab on the Spectrum Analyzer toolstrip.
In the **Configuration** section, click
**Settings**. In the Spectrum Analyzer Settings window that
appears, under **Display and Labels**, select **Show
Grid**.

**Data Types: **`logical`

`ShowLegend`

— Show or hide legend

`false`

(default) | `true`

Show or hide the legend, specified as `true`

or
`false`

. To show a legend with the input names, set this property
to `true`

.

Use the legend to control which signals are visible. In the scope legend, click a
signal name to hide the signal in the scope. To show the signal, click the signal name
again. To show only one signal, right-click the signal name. To show all signals,
press **Esc**.

**Tunable: **Yes

#### Scope Window Use

Click the **Analyzer** tab on the Spectrum Analyzer toolstrip.
To see the legend, click **Legend** in the
**Configuration** section.

**Data Types: **`logical`

`ShowColorbar`

— Show or hide color bar

`true`

(default) | `false`

Show or hide color bar, specified as `true`

or
`false`

.

**Tunable: **Yes

#### Dependencies

To enable this property, set the `ViewType`

property to `"spectrogram"`

or
`"spectrum-and-spectrogram"`

.

#### Scope Window Use

Click the **Analyzer** tab on the Spectrum Analyzer toolstrip.
To see the color bar, click **Colorbar** in the
**Configuration** section.

To enable the **Colorbar**, select
**Spectrogram** or **Spectrum** and
**Spectrogram** in the **Analyzer** tab.

**Data Types: **`logical`

`ChannelNames`

— Input data channel names

empty cell (default) | cell array of character vectors

Input data channel names, specified as a cell array of character vectors. The names you specify in this property appear in the following locations:

legend

**Spectrum Analyzer Settings**>**Color and styling**section**Measurements**and**Channel Measurements**tabs

If you do not specify channel names, the Spectrum Analyzer names the channels as
`Channel 1`

, `Channel 2`

, and so on.

**Tunable: **Yes

#### Dependency

To see the channel names, set `ShowLegend`

to `true`

.

#### Scope Window Use

Click the **Analyzer** tab on the Spectrum Analyzer toolstrip.
To see the legend, click **Legend** in the
**Configuration** section.

**Data Types: **`char`

`AxesLayout`

— Layout of axes

`"vertical"`

(default) | `"horizontal"`

Layout of the axes, specified as one of `"horizontal"`

or
`"vertical"`

.

**Tunable: **Yes

#### Dependency

To enable this property, set `ViewType`

to `"spectrum-and-spectrogram"`

.

#### Scope Window Use

Click the **Analyzer** tab on the Spectrum Analyzer toolstrip.
Select **Spectrum** and **Spectrogram**. In the
**Configuration** section, select and update
**Layout**.

**Data Types: **`char`

| `string`

## Usage

### Description

`scope(`

displays the frequency
spectrum of the time-domain signal in the Spectrum Analyzer. If
`signal`

)`signal`

is a frequency-domain signal, the signal is displayed
directly in the Spectrum Analyzer.

`scope(signal1,signal2,...,signalN)`

displays the frequency
spectrum of multiple signals in the Spectrum Analyzer. The number of channels in each
signal can be different but the frame size of each signal should be the same.

### Input Arguments

`signal`

— Input signal or signals to visualize

scalar | vector | matrix

Input signal or signals to visualize, specified as a scalar, vector, or a matrix. The number of channels in each signal can be different but the frame size of each signal should be the same.

This scope supports variable-size input signals. That is, the frame size (number of rows) of the input signals can change during simulation, but the number of channels (number of columns) cannot change.

When you set the `InputDomain`

property to `"time"`

, the input signals can
be real or complex. When you set the `InputDomain`

property to
`"frequency"`

, the input signals must be real.

**Example: **`scope(signal1,signal2)`

#### Scope Window Use

To change the appearance of signals in the Spectrum Analyzer, click the
**Analyzer** tab and then click
**Settings**. In the Spectrum Analyzer Settings window, under
**Color and styling**, select a signal and modify its style,
width, color, and marker type.

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `uint8`

| `uint16`

| `uint32`

| `uint64`

| `fi`

**Complex Number Support: **Yes

## Object Functions

### Specific to spectrumAnalyzer

`generateScript` | Generate MATLAB script to create scope with current settings |

`getMeasurementsData` | Get the current measurement data displayed on the spectrum analyzer |

`getSpectralMaskStatus` | Get test results of current spectral mask |

`getSpectrumData` | Save spectrum data shown in spectrum analyzer |

`isNewDataReady` | Check spectrum analyzer for new data |

### Specific to Scopes

**Note**

If you want to restart the simulation from the beginning, call
`reset`

to clear the scope window display. Do not call
`reset`

after calling `release`

.

## Examples

### Spectrum Analyzer for One-Sided Power Spectrum

View a one-sided power spectrum made from the sum of fixed real sine waves with different amplitudes and frequencies.

Fs = 100e6; % Sample rate fSz = 5000; % Frame size sin1 = dsp.SineWave(1e0,5e6,0,SamplesPerFrame=fSz,SampleRate=Fs); sin2 = dsp.SineWave(1e-1,15e6,0,SamplesPerFrame=fSz,SampleRate=Fs); sin3 = dsp.SineWave(1e-2,25e6,0,SamplesPerFrame=fSz,SampleRate=Fs); sin4 = dsp.SineWave(1e-3,35e6,0,SamplesPerFrame=fSz,SampleRate=Fs); sin5 = dsp.SineWave(1e-4,45e6,0,SamplesPerFrame=fSz,SampleRate=Fs); scope = spectrumAnalyzer(SampleRate=Fs,AveragingMethod="exponential",... PlotAsTwoSidedSpectrum=false,... RBWSource="auto",SpectrumUnits="dBW"); for idx = 1:250 y1 = sin1(); y2 = sin2(); y3 = sin3(); y4 = sin4(); y5 = sin5(); scope(y1+y2+y3+y4+y5+0.0001*randn(fSz,1)); end

Call the `release`

function to let property values and input characteristics change. The scope automatically scales the axes.

release(scope)

Run the `clear`

function to close the Spectrum Analyzer window.

`clear('scope');`

### Spectrum Analyzer For Two-Sided Power Spectrum

View a two-sided power spectrum of a noisy sine wave on the Spectrum Analyzer.

sin = dsp.SineWave(Frequency=100,SampleRate=1000,... SamplesPerFrame=1000); scope = spectrumAnalyzer(SampleRate=sin.SampleRate); for ii = 1:250 x = sin() + 0.05*randn(1000,1); scope(x); end

Call the `release`

function to change property values and input characteristics. The scope automatically scales the axes and updates the display one more time if the internal buffer contains any more data.

release(scope);

Run the MATLAB `clear`

function to close the Spectrum Analyzer window.

`clear('scope');`

### Spectrogram of Chirp Signal

Plot the spectrogram for a chirp signal with added random noise.

Fs = 233e3; frameSize = 20e3; chirp = dsp.Chirp(SampleRate=Fs,SamplesPerFrame=frameSize,... InitialFrequency=11e3,TargetFrequency=11e3+55e3); scope = spectrumAnalyzer(SampleRate=Fs,... AveragingMethod="exponential",... ForgettingFactor=0.3,ViewType="spectrogram",... RBWSource="property",RBW=500,... TimeSpanSource="property",TimeSpan=2); scope.PlotAsTwoSidedSpectrum = false; for idx = 1:50 y = chirp()+0.05*randn(frameSize,1); scope(y); end release(scope)

### Display Frequency Input from Spectral Estimation

Use the Spectrum Analyzer to display frequency input from spectral estimates of sinusoids embedded in white Gaussian noise.

**Initialization**

Create two `dsp.SpectrumEstimator`

objects. Set one object to use the Welch-based spectral estimation technique with a Hann window, set the other object to use the filter bank estimation. Specify a noisy sine wave input signal with four sinusoids at 0.16, 0.2, 0.205, and 0.25 cycles per sample. View the spectral estimate using the `spectrumAnalyzer`

object.

FrameSize = 420; Fs = 1; Frequency = [0.16 0.2 0.205 0.25]; sinegen = dsp.SineWave(SampleRate=Fs,SamplesPerFrame=FrameSize,... Frequency=Frequency,Amplitude=[2e-5 1 0.05 0.5]); NoiseVar = 1e-10; numAvgs = 8; hannEstimator = dsp.SpectrumEstimator(PowerUnits="dBm",... Window="Hann",FrequencyRange="onesided",... SpectralAverages=numAvgs,SampleRate=Fs); filterBankEstimator = dsp.SpectrumEstimator(PowerUnits="dBm",... Method="Filter bank",FrequencyRange="onesided",... SpectralAverages=numAvgs,SampleRate=Fs); spectrumPlotter = spectrumAnalyzer(InputDomain="frequency",... SampleRate=Fs,SpectrumUnits="dBm",... YLimits=[-120,40],PlotAsTwoSidedSpectrum=false,... ChannelNames={'Hann window','Filter bank'},ShowLegend=true);

**Streaming**

Stream the input. Compare the spectral estimates in the spectrum analyzer.

for i = 1:1000 x = sum(sinegen(),2) + sqrt(NoiseVar)*randn(FrameSize,1); Pse_hann = hannEstimator(x); Pfb = filterBankEstimator(x); spectrumPlotter([Pse_hann,Pfb]) end

### Obtain Measurements Data Programmatically for `spectrumAnalyzer`

object

Compute and display the power spectrum of a noisy sinusoidal input signal using the `spectrumAnalyzer`

MATLAB® object. Measure the peaks, cursor placements, adjacent channel power ratio, and distortion values in the spectrum by enabling these properties:

`PeakFinder`

`CursorMeasurements`

`ChannelMeasurements`

`DistortionMeasurements`

**Initialization**

The input sine wave has two frequencies: 1000 Hz and 5000 Hz. Create two `dsp.SineWave`

System objects to generate these two frequencies. Create a `spectrumAnalyzer`

object to compute and display the power spectrum.

Fs = 44100; Sineobject1 = dsp.SineWave(SamplesPerFrame=1024,PhaseOffset=10,... SampleRate=Fs,Frequency=1000); Sineobject2 = dsp.SineWave(SamplesPerFrame=1024,... SampleRate=Fs,Frequency=5000); SA = spectrumAnalyzer(SampleRate=Fs,SpectrumType="power",... PlotAsTwoSidedSpectrum=false,ChannelNames={'Power spectrum of the input'},... YLimits=[-120 40],ShowLegend=true);

**Enable Measurements Data**

To obtain the measurements, set the `Enabled`

property to `true`

.

SA.CursorMeasurements.Enabled = true; SA.ChannelMeasurements.Enabled = true; SA.PeakFinder.Enabled = true; SA.DistortionMeasurements.Enabled = true;

**Use getMeasurementsData**

Stream in the noisy sine wave input signal and estimate the power spectrum of the signal using the spectrum analyzer. Measure the characteristics of the spectrum. Use the `getMeasurementsData`

function to obtain these measurements programmatically. The `isNewDataReady`

function returns `true`

when there is new spectrum data. Store the measured data in the variable `data`

.

data = []; for Iter = 1:1000 Sinewave1 = Sineobject1(); Sinewave2 = Sineobject2(); Input = Sinewave1 + Sinewave2; NoisyInput = Input + 0.001*randn(1024,1); SA(NoisyInput); if SA.isNewDataReady data = [data;getMeasurementsData(SA)]; end end

The right side of the spectrum analyzer shows the measurement panes you enabled. The values in these panes match the values in the last time step of the `data`

variable. You can access the individual fields of `data`

to obtain the various measurements programmatically.

**Compare Peak Values**

Use the `PeakFinder`

property to obtain peak values. Verify that the peak values in the last time step of `data`

match the values shown on the spectrum analyzer plot.

peakvalues = data.PeakFinder(end).Value

`peakvalues = `*3×1*
26.9261
24.1149
-46.3163

frequencieskHz = data.PeakFinder(end).Frequency/1000

`frequencieskHz = `*3×1*
4.9957
0.9905
0.0646

## Tips

## Algorithms

### Spectrum Estimation — Filter Bank

When you choose the `Filter Bank`

method, the Spectrum Analyzer
uses an analysis filter bank to estimate the power spectrum.

The filter bank splits the broadband input signal *x(n)*, of sample
rate *fs*, into multiple narrow band signals
*y _{0}(m)*,

*y*, … ,

_{1}(m)*y*, of sample rate

_{M-1}(m)*fs/M*.

The variable *M* represents the number of frequency bands in the filter
bank. In the Spectrum Analyzer, *M* is equal to the number of data points
needed to achieve the specified RBW value or 1024, whichever is larger. For more information
on the analysis filter bank and its implementation, see the More About and the Algorithm sections in
`dsp.Channelizer`

.

After the Spectrum Analyzer splits the broadband input signal into multiple narrow
bands, it computes the power in each narrow frequency band using the following equation.
Each *Z _{i}* value is the power estimate over that
narrow frequency band.

$${Z}_{i}=\frac{1}{L}{\displaystyle \sum _{m=0}^{L-1}{\left|{y}_{i}[m]\right|}^{2}}$$

*L* is length of the narrowband signal
*y _{i}(m)* and

*i*= 1, 2, …,

*M*−1.

The power values in all the narrow frequency bands (denoted by
*Z _{i}*) form the

*Z*vector.

$$Z=[{Z}_{0},\text{\hspace{0.17em}}{Z}_{1},\text{\hspace{0.17em}}{Z}_{2},\cdots ,{Z}_{M-1}]$$

The Spectrum Analyzer averages the current *Z* vector with the previous
*Z* vectors using one of the two moving average methods: video bandwidth
or exponential weighting. The output of the averaging operation forms the spectral estimate
vector. For details on the two averaging methods, see Averaging Method.

The Spectrum Analyzer uses the value you specify in the **RBW (Hz)** to
determine the input frame length. To view the **RBW (Hz)** in the scope,
click the **Analyzer** tab on the Spectrum Analyzer toolstrip and navigate
to the **Bandwidth** section.

Spectrum Analyzer requires a minimum number of samples to compute a spectral estimate.
This value is directly related to the resolution bandwidth property **RBW
(Hz)**.

When you set **RBW (Hz)** to:

`Auto`

–– The Spectrum Analyzer requires 1024 samples to update the display. The Spectrum Analyzer determines the appropriate resolution bandwidth to ensure that there are 1024 RBW intervals over the specified frequency span. When you set**RBW (Hz)**to`Auto`

, the Spectrum Analyzer calculates using this equation.$$RB{W}_{auto}=\frac{span}{1024}$$

scalar value –– The Spectrum Analyzer calculates the number of samples

*N*using this equation._{samples}$${N}_{samples}=\frac{{F}_{s}}{RBW}$$

*F*is the sample rate of the input signal as specified in the_{s}**Sample Rate (Hz)**property. To view the**Sample Rate (Hz)**in the scope, click the**Analyzer**tab on the Spectrum Analyzer toolstrip and navigate to the**Bandwidth**section.When you specify a resolution bandwidth using the

**RBW (Hz)**parameter, you must specify a value such that there are at least two RBW intervals over the specified frequency span. The ratio of the overall span to RBW must be greater than two:$$\frac{span}{RBW}>2$$

*span* is the frequency span over which the Spectrum Analyzer computes
and plots the spectrum. To view the **Span (Hz)** in the scope, click the
**Estimation** tab on the Spectrum Analyzer toolstrip and navigate to the
**Frequency Options** section. To enable this property, set
**Frequency Span** to ```
Span and Center
Frequency
```

.

When the number of input samples is not sufficient to achieve the specified resolution bandwidth, the Spectrum Analyzer displays a message similar to this one.

The Spectrum Analyzer removes this message and displays a spectral estimate once you provide enough input samples.

### Spectrum Estimation — Welch's Method

When you choose the `Welch`

method, the power spectrum estimate
is averaged modified periodograms.

Given the input signal `x`

, the Spectrum Analyzer:

Multiplies

`x`

by the given window and scales the result by the window power. The Spectrum Analyzer uses the**RBW (Hz)**to determine the input frame length. To view the**RBW (Hz)**in the scope, click the**Analyzer**tab on the Spectrum Analyzer toolstrip and navigate to the**Bandwidth**section.Computes the FFT of the signal,

`Y`

, and then calculates the square magnitude using`Z = Y.*conj(Y)`

.Computes the current power spectrum estimate by calculating the moving average of the last

*N*number of*Z*vectors, and then scales the answer by the sample rate. For more information on the moving average methods, see Averaging Method.

**Number of Samples Per Update (**

*N*)_{samples}The Spectrum Analyzer requires a minimum number of samples to compute a spectral estimate. This value is directly related to resolution bandwidth (RBW).

$${N}_{samples}=\frac{\left(1-\frac{{O}_{p}}{100}\right)\times NENBW\times {F}_{s}}{RBW}$$

where O_{p} is the overlap percentage, NENBW is the
normalized effective noise bandwidth, F_{s} is the input sample rate, and RBW is the
resolution bandwidth.

The Spectrum Analyzer shows the value of
*N _{samples}* in the Spectrum Analyzer status bar.
To enable the display, right-click the status bar at the bottom of the Spectrum Analyzer
window, and select

`Samples/Update`

from the list of options. All the enabled parameters appear in the status bar.

You can enable `Samples/Update`

only when you set **Input
Domain** to `Time`

and **Method** to
`Welch`

in the **Estimation** tab on the
Spectrum Analyzer toolstrip.

**Normalized Effective Noise Bandwidth (NENBW)**

The normalized effective noise bandwidth *NENBW* is a window
parameter determined by the window length and the window type.

$$NENBW={N}_{window}\times \frac{{\displaystyle \sum _{n=1}^{{N}_{window}}{w}^{2}(n)}}{{\left[{\displaystyle \sum _{n=1}^{{N}_{window}}w(n)}\right]}^{2}}$$

*w*(*n*) denotes the vector of window coefficients
(calculated internally). *N _{window}* is the window
length the object needs to compute one spectral update, and is directly related to the
resolution bandwidth and normalized effective noise bandwidth.

$${N}_{window}=\frac{NENBW\times {F}_{s}}{RBW}$$

The Spectrum Analyzer shows the value of *NENBW* in the Spectrum
Analyzer status bar. To enable the display, right-click the status bar at the bottom of
the Spectrum Analyzer window, and select `NENBW`

from the list of
options.

You can enable `NENBW`

only when you set **Input
Domain** to `Time`

and **Method** to
`Welch`

in the **Estimation** tab on the
Spectrum Analyzer toolstrip.

**Overlap Percentage (**

*O*)_{p}The overlap percentage *O _{p}* is the value you
specify in the

**Overlap %**property. To view the

**Overlap %**in the scope, click the

**Estimation**tab on the Spectrum Analyzer toolstrip and navigate to the

**Window Options**section.

When you increase the overlap percentage, the Spectrum Analyzer needs fewer new input samples to compute a new spectral update.

O_{p} | N_{samples} |
---|---|

0% | 100 |

50% | 50 |

80% | 20 |

**Input Sample Rate (**

*Fs*)*F _{s}* is the sample rate of the input signal.
To view the

**Sample Rate (Hz)**in the scope, click the

**Analyzer**tab on the Spectrum Analyzer toolstrip and navigate to the

**Bandwidth**section. You can enable this property in the status bar at the bottom of the Spectrum Analyzer window. Right-click the status bar and select

`Sample Rate`

.**Resolution Bandwidth (RBW)**

Resolution bandwidth controls the spectral resolution of the displayed signal. The RBW value determines the spacing between frequencies that can be resolved. A smaller value gives a higher spectral resolution and lowers the noise floor. That is, the Spectrum Analyzer can resolve frequencies that are closer to each other. However, this comes at the cost of a longer sweep time.

You can set the resolution bandwidth through the **RBW (Hz)**
property. To view the **RBW (Hz)** in the scope, click the
**Analyzer** tab on the Spectrum Analyzer toolstrip and navigate to the
**Bandwidth** section.

When you set **RBW (Hz)** to:

`Auto`

–– The Spectrum Analyzer requires 1024 samples to update the display. The Spectrum Analyzer determines the appropriate resolution bandwidth to ensure that there are 1024 RBW intervals over the specified frequency span. When you set**RBW (Hz)**to`Auto`

, the Spectrum Analyzer calculates using this equation.$$RB{W}_{auto}=\frac{span}{1024}$$

scalar value –– Specify a value such that there are at least two RBW intervals over the specified frequency span. The ratio of the overall span to RBW must be greater than two:

$$\frac{span}{RBW}>2$$

*span* is the frequency span over which the Spectrum Analyzer
computes and plots the spectrum. Spectrum Analyzer shows the span through the
**Span (Hz)** property. To view the **Span (Hz)** in
the scope, click the **Estimation** tab on the Spectrum Analyzer
toolstrip, navigate to the **Frequency Options** section, and set
**Frequency Span** to ```
Span and Center
Frequency
```

.

When the number of input samples is not sufficient to achieve the specified resolution bandwidth, the Spectrum Analyzer displays a message similar to this one:

The Spectrum Analyzer removes this message and displays a spectral estimate once you provide enough input samples.

You can enable this property in the status bar at the bottom of the Spectrum Analyzer
window. Right-click the status bar and select `RBW`

.

### Nyquist Frequency Interval

When you set the `PlotAsTwoSidedSpectrum`

property to `true`

, the interval is $$\left[-\frac{SampleRate}{2},\frac{SampleRate}{2}\right]+FrequencyOffset$$ hertz.

When you set the `PlotAsTwoSidedSpectrum`

property to
`false`

, the interval is $$\left[0,\frac{SampleRate}{2}\right]+FrequencyOffset$$ hertz.

### Periodogram and Spectrogram

The Spectrum Analyzer calculates and plots the power spectrum, power spectrum density,
and RMS using the modified *Periodogram* estimator. For more
information about the Periodogram method, see `periodogram`

.

Power Spectral Density — The power spectral density (PSD) is given by this equation.

$$\mathrm{PSD}\left(f\right)=\frac{1}{P}{\displaystyle \sum _{p=1}^{P}\frac{{\left|{\displaystyle \sum _{n=1}^{{N}_{FFT}}{x}^{p}\left[n\right]{e}^{-j2\pi f(n-1)T}}\right|}^{2}}{{F}_{s}\times {\displaystyle \sum _{n=1}^{{N}_{window}}{w}^{2}\left[n\right]}}}$$

In this equation, *x*[*n*] is the discrete input
signal. The Spectrum Analyzer generates as many overlapping windows as possible in every
input signal frame, with each window denoted as
*x ^{(p)}*[

*n*], and then computes their periodograms. The Spectrum Analyzer displays a running average of the

*P*most current periodograms.

Power Spectrum — The power spectrum is the product of the power spectral density and the resolution bandwidth, as given by this equation.

$${P}_{spectrum}\left(f\right)=\mathrm{PSD}\left(f\right)\times RBW=\mathrm{PSD}\left(f\right)\times \frac{{F}_{s}\times NENBW}{{N}_{window}}=\frac{1}{P}{\displaystyle \sum _{p=1}^{P}\frac{{\left|{\displaystyle \sum _{n=1}^{{N}_{FFT}}{x}^{p}\left[n\right]{e}^{-j2\pi f(n-1)T}}\right|}^{2}}{{\left[{\displaystyle \sum _{n=1}^{{N}_{window}}w\left[n\right]}\right]}^{2}}}$$

Spectrogram — You can plot any power as a spectrogram. Each
line of the spectrogram is one periodogram. The time resolution of each line is
1/*RBW*, which is the minimum attainable resolution. Achieving the
resolution you want may require combining several periodograms. You then use interpolation
to calculate noninteger values of 1/*RBW*. In the spectrogram display, time
scrolls from top to bottom, so the most recent data is shown at the top of the display. The
offset shows the time value at which the center of the most current spectrogram line
occurred.

### Frequency Vector

When you set **Frequency (Hz)** to `Auto`

, the
software calculates the frequency vector for the frequency-domain input.

When you set the `PlotAsTwoSidedSpectrum`

property to true, the frequency vector is:

$$\left[-\frac{SampleRate}{2},\frac{SampleRate}{2}\right]$$

When you set the `PlotAsTwoSidedSpectrum`

property to false, the frequency vector is:

$$\left[0,\frac{SampleRate}{2}\right]$$

### Occupied BW

The Spectrum Analyzer calculates *Occupied BW* using these steps.

Calculate the total power in the measured frequency range.

Determine the lower frequency value. Starting at the lowest frequency in the range and moving upward, sum the power distributed in each frequency until the result is

$$\frac{100-OccupiedBW\%}{2}$$

of the total power.

Determine the upper frequency value. Starting at the highest frequency in the range and moving downward, sum the power distributed in each frequency until the result reaches

$$\frac{100-OccupiedBW\%}{2}$$

of the total power.

The bandwidth between the lower and upper power frequency values is the occupied bandwidth.

The frequency halfway between the lower and upper frequency values is the center frequency.

### Distortion Measurements

The Spectrum Analyzer calculates *Distortion Measurements* using
these steps.

Estimate spectral content by finding peaks in the spectrum. When the algorithm detects a peak, it records the width of the peak and clears all monotonically decreasing values. That is, the algorithm treats all these values as if they belong to the peak. Using this method, the algorithm removes all spectral content centered at DC (0 Hz) from the spectrum and records the amount of bandwidth cleared (

*W*)._{0}Determine the fundamental power (

*P*) from the remaining maximum value of the displayed spectrum. Create a local estimate (_{1}*Fe*) of the fundamental frequency by computing the central moment of the power near the peak. Record the bandwidth of the fundamental power content (_{1}*W*). Then remove the power from the fundamental as in step 1._{1}Determine the power and width of the higher-order harmonics (

*P*,_{2}*W*,_{2}*P*,_{3}*W*, etc.) in succession by examining the frequencies closest to the appropriate multiple of the local estimate (_{3}*Fe*). Remove any spectral content that decreases monotonically about the harmonic frequency from the spectrum before proceeding to the next harmonic._{1}After removing the DC, fundamental, and harmonic content from the spectrum, examine the power of the remaining spectrum for its sum (

*P*), peak value (_{remaining}*P*), and median value (_{maxspur}*P*)._{estnoise}Compute the sum of all the removed bandwidth as

*W*=_{sum}*W*+_{0}*W*+_{1}*W*+...+_{2}*W*._{n}Compute the sum of powers of the second and higher-order harmonics as

*P*=_{harmonic}*P*+_{2}*P*+_{3}*P*+...+_{4}*P*._{n}Estimate the sum of the noise power as:

$${P}_{noise}=({P}_{remaining}\cdot dF+{P}_{est.noise}\cdot {W}_{sum})/RBW$$

Where

*dF*is the absolute difference between frequency bins, and*RBW*is the resolution bandwidth of the window.Then compute the metrics for SNR, THD, SINAD, and SFDR from the estimates.

$$\begin{array}{l}THD=10\cdot {\mathrm{log}}_{10}\left(\frac{{P}_{harmonic}}{{P}_{1}}\right)\\ SINAD=10\cdot {\mathrm{log}}_{10}\left(\frac{{P}_{1}}{{P}_{harmonic}+{P}_{noise}}\right)\\ SNR=10\cdot {\mathrm{log}}_{10}\left(\frac{{P}_{1}}{{P}_{noise}}\right)\\ SFDR=10\cdot {\mathrm{log}}_{10}\left(\frac{{P}_{1}}{\mathrm{max}\left({P}_{maxspur},\mathrm{max}\left({P}_{2},{P}_{3},\mathrm{...},{P}_{n}\right)\right)}\right)\end{array}$$

### Harmonic Measurements

The harmonic distortion measurements use the spectrum trace shown in the display as the input to the measurements. The default

`Hann`

window setting of the Spectrum Analyzer might exhibit leakage that can completely mask the noise floor of the measured signal.The harmonic measurements attempt to correct for leakage by ignoring all frequency content that decreases monotonically away from the maximum of harmonic peaks. If the window leakage covers more than 70% of the frequency bandwidth in your spectrum, you may see a blank reading (–) reported for

**SNR**and**SINAD**. If your application can tolerate the increased equivalent noise bandwidth (ENBW), consider using a Kaiser window with a high attenuation (up to 330 dB) to minimize spectral leakage.Ignore the DC component.

After windowing, the width of each harmonic component masks the noise power in the neighborhood of the fundamental frequency and harmonics. To estimate the noise power in each region, the Spectrum Analyzer computes the median noise level in the nonharmonic areas of the spectrum. It then extrapolates that value into each region.

*N*^{th}order intermodulation products occur at*A***F1*+*B***F2*,where

*F1*and*F2*are the sinusoid input frequencies and |*A*| + |*B*| =*N*.*A*and*B*are integer values.For intermodulation measurements, compute the third-order intercept (TOI) point as follows.

*TOI*=_{lower}*P*+ (_{F1}*P*-_{F2}*P*)/2_{(2F1-F2)}*TOI*=_{upper}*P*+ (_{F2}*P*-_{F1}*P*)/2_{(2F2-F1)}*TOI*= + (*TOI*+_{lower}*TOI*)/2_{upper}

Where

*P*is power in decibels of the measured power referenced to 1 milliwatt (dBm).

### Averaging Method

The Spectrum Analyzer can calculate the moving average using two methods:

Video bandwidth — The Spectrum Analyzer uses a time-domain lowpass filter to smooth the noise in the signal. The video bandwidth (VBW) filter smoothes the trace and decreases noise, and the Spectrum Analyzer applies the filter to the data before displaying it.

Video bandwidth is the bandwidth of a lowpass filter that is used to average or smooth the noise in the signal before it is displayed on the Spectrum Analyzer. Video bandwidth does not affect the level of the noise (noise floor), but only increases the signal-to-noise ratio and smoothes the trace of the noise.

When you decrease the value of VBW, the signal-to-noise ratio improves.

The cutoff frequency of the video bandwidth filter is given by:

$${\omega}_{c}=\frac{2\pi VBW}{{F}_{s}/NFFT}$$

where

*Fs*is the input sample rate and NFFT is the number of FFT points.The Spectrum Analyzer shows the values of sample rate, VBW, and NFFT in the status bar at the bottom of the display. To enable, right-click the status bar and select

`Sample Rate`

,`VBW`

, and`NFFT`

.Exponential — The moving average algorithm uses the exponential weighting method to update the weights and compute the moving average recursively for each

*Z*vector that comes in by using the following recursive equations:$$\begin{array}{l}{w}_{N}=\lambda {w}_{N-1}+1\\ {\overline{z}}_{N}=\left(1-\frac{1}{{w}_{N}}\right){\overline{z}}_{N-1}+\left(\frac{1}{{w}_{N}}\right){z}_{N}\end{array}$$

λ — Forgetting factor

$${w}_{N}$$ — Weighting factor applied to the current

*Z*vector$${z}_{N}$$ — Current

*Z*vector$${\overline{z}}_{N-1}$$ — Moving average until the previous

*Z*vector$$\left(1-\frac{1}{{w}_{N}}\right){\overline{z}}_{N-1}$$ — Effect of the previous

*Z*vectors on the average$${\overline{z}}_{N}$$ — Moving average including the current

*Z*vector

## Extended Capabilities

### C/C++ Code Generation

Generate C and C++ code using MATLAB® Coder™.

Usage notes and limitations:

The

`spectrumAnalyzer`

object supports MEX code generation by treating the calls to the object as extrinsic.The object does not support code generation for standalone applications.

## Version History

**Introduced in R2022a**

## Apri esempio

Si dispone di una versione modificata di questo esempio. Desideri aprire questo esempio con le tue modifiche?

## Comando MATLAB

Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:

Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.

# Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)