# Documentation

### This is machine translation

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

# dsp.SpectrumAnalyzer System object

Display frequency spectrum of time-domain signals

## Description

The Spectrum Analyzer System object™ displays the frequency spectrum of time-domain signals. This scope supports variable-size input, which allows the input frame size to change. Frame size is the first dimension of the input vector. The number of input channels must remain consstop tant.

To display the spectra of signals in the Spectrum Analyzer:

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

2. Call the object with arguments, as if it were a function.

## Creation

### Syntax

``scope = dsp.SpectrumAnalyzer``
``scope = dsp.SpectrumAnalyzer(ports)``
``scope = dsp.SpectrumAnalyzer(Name,Value)``

### Description

````scope = dsp.SpectrumAnalyzer` creates a Spectrum Analyzer System object. This object displays the frequency spectrum of real- and complex-valued floating- and fixed-point signals.`scope = dsp.SpectrumAnalyzer(ports)` creates a Spectrum Analyzer object and sets the NumInputPorts property to the value of `ports`.`scope = dsp.SpectrumAnalyzer(Name,Value)` sets properties using one or more name-value pairs. Enclose each property name in single quotes.```

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

### Frequently Used

Number of input ports, specified as a positive integer. Each signal coming through an input port becomes a separate channel in the scope. You must invoke the scope with the same number of inputs as the value of this property.

Specify the sample rate, in hertz, of the input signals as a finite numeric scalar.

#### UI Use

Open the Spectrum Settings. In the Main options section, set Sample rate (Hz).

Specify the spectrum type to display.

`'Power'` - Power spectrum

`'Power density'` - Power spectral density. The power spectral density is the magnitude squared of the spectrum normalized to a bandwidth of 1 hertz.

`'RMS'` - Root mean squared. The root mean squared shows the square root of the sum of the squared means. This option is useful when viewing the frequency of voltage or current signals.

Tunable: Yes

#### UI Use

Open the Spectrum Settings. In the Main options section, set Type.

Specify the spectrum type as one of `'Spectrum'`, `'Spectrogram'`, or `'Spectrum and spectrogram'`.

• `'Spectrum'` — shows the power spectrum.

• `'Spectrogram'` — shows frequency content over time. Each line of the spectrogram is one periodogram. Time scrolls from the bottom to the top of the display. The most recent spectrogram update is at the bottom of the display.

• `'Spectrum and Spectrogram'` — shows a dual view of a spectrum and spectrogram.

Tunable: Yes

#### UI Use

Open the Spectrum Settings. In the Main options section, set View.

Specify the spectrum estimation method as `Welch` or `Filter bank`.

#### UI Use

Open the Spectrum Settings. In the Main options section, set Method.

Specify the number of filter taps or coefficients for each frequency band. This corresponds to the number of filter coefficients per polyphase branch. The total number of filter coefficients is equal to `NumTapsPerBand` + FFTLength.

#### Dependency

To enable this property, set Method to `'Filter Bank'`

#### UI Use

Open the Spectrum Settings. In the Main options section, set Taps per band.

The Spectrum Analyzer computes the current power spectrum estimate by computing a running average of the last N power spectrum estimates. This property defines N.

Tunable: Yes

#### Dependency

To enable this property, set ViewType to `'Spectrum'`.

#### UI Use

Open the Spectrum Settings. In the Trace options section, set Averages.

• `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 this property is `false`, Spectrum Analyzer uses power-folding. The y-axis values are twice the amplitude that they would be if this property were set 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 of the Nyquist rate. For more information, see `pwelch`.

#### UI Use

Open the Spectrum Settings. In the Trace options section, select Two-sided spectrum.

• `'Log'` - displays the frequencies on the x-axis on a logarithmic scale. To use the `'Log'` setting, you must also set the PlotAsTwoSidedSpectrum property to `false`.

• `'Linear'` - displays the frequencies on the x-axis on a linear scale. To use the `'Linear'` setting, you must also set the PlotAsTwoSidedSpectrum property to `true`.

Tunable: Yes

#### UI Use

Open the Spectrum Settings. In the Trace options section, set Scale.

Specify when the scope automatically scales the axes. Valid values are:

• `'Auto'` — The scope scales the axes as needed 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.

• `'Updates'` — The scope scales the axes once after 10 updates.

#### UI Use

Select Tools > Axes Scaling.

Specify the frequency resolution method of the Spectrum Analyzer.

• `'RBW'` - the RBWSource and RBW properties control the frequency resolution (in Hz) of the analyzer. The FFT length is the window length that results from achieving the specified RBW value or 1024, whichever is larger.

• `'WindowLength'` - applies only when the Method property is set to `'Welch'`. The WindowLength property controls the frequency resolution. You can control the number of FFT points only when the `FrequencyResolutionMethod` property is `'WindowLength'`.

• `'NumFrequencyBands'` - applies only when the Method property is set to `'Filter Bank'`. The FFTLengthSource and FFTLength properties control the frequency resolution.

Tunable: Yes

#### UI Use

Open the Spectrum Settings. In the Main options section, set the frequency resolution method by selecting the RBW (Hz) dropdown.

Specify the layout type as `'Horizontal'` or `'Vertical'`. A vertical layout stacks the spectrum above the spectrogram. A horizontal layout puts the two views side-by-side.

Tunable: Yes

#### Dependency

To enable this property, set ViewType to ```'Spectrum and spectrogram'```.

#### UI Use

Open the Spectrum Settings. Set Axes layout.

Specify the source of the resolution bandwidth (RBW) as either `'Auto'` or `'Property'`.

• `'Auto'` - The Spectrum Analyzer adjusts the spectral estimation resolution to ensures that there are 1024 RBW intervals over the defined frequency span.

• `'Property'` - Specify the resolution bandwidth directly using the RBW property.

Tunable: Yes

#### Dependency

To enable this property, set the FrequencyResolutionMethod property to `'RBW'`.

#### UI Use

Open the Spectrum Settings. In the Main options section, set RBW (Hz).

RBW controls the spectral resolution of Spectrum Analyzer. Specify the resolution bandwidth in hertz as a real positive scalar. You must specify a value to ensure that there are at least two RBW intervals over the specified frequency span. Thus, the ratio of the overall span to RBW must be greater than two:

`$\frac{span}{RBW}>2$`
You can specify the overall span in different ways based on how you set the FrequencySpan property.

Tunable: Yes

To enable, set:

#### UI Use

Open the Spectrum Settings. In the Main options section, set RBW (Hz).

Control the frequency resolution by specifying the window length, in samples used to compute the spectral estimates. The window length must be an integer scalar greater than 2.

Tunable: Yes

#### Dependencies

To enable this property, set:

• FrequencyResolutionMethod to `'WindowLength'`, which controls the frequency resolution based on your window length setting

• Method to `'Welch'`

#### UI Use

Open the Spectrum Settings. Change the RBW (Hz) dropdown to `Window length`.

• `'Auto'` - sets the FFT length to the window length specified in the WindowLength property or 1024, whichever is larger.

• `'Property'` - number of FFT points using the FFTLength property. `FFTLength` must be greater than `WindowLength`.

Tunable: Yes

#### Dependency

To enable this property, set FrequencyResolutionMethod to `'WindowLength'`.

#### UI Use

Open the Spectrum Settings. In the Main options section, next to the RBW (Hz) option, enter a number or select `Auto`.

Specify the length of the FFT that the Spectrum Analyzer uses to compute spectral estimates.

If FrequencyResolutionMethod is `'RBW'`, the FFT length is set as the window length required to achieve the specified resolution bandwidth value or 1024, whichever is larger.

Tunable: Yes

#### Dependencies

To use this property, the following must be true:

#### UI Use

Open the Spectrum Settings. In the Main options section, next to the RBW (Hz) option, enter a number or select `Auto`.

• scalar - Apply the same frequency offset to all channels, specified in hertz.

• vector - apply a specific frequency offset for each channel, specify a vector of frequencies. The vector length must be equal to number of input channels.

The Frequency-axis values are offset by the values specified in this property. 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

#### UI Use

Open the Spectrum Settings. In the Trace options section, set Offset (Hz).

• `'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

#### UI Use

Open the Spectrum Settings. In the Main options section, select Full frequency span for `'Full'`. Otherwise, clear the Full frequency span check box and choose between `Span` or `FStart`.

Start of the frequency interval over which spectrum is computed, specified in hertz as a real scalar. 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 FrequencySpan to ```'Start and stop frequencies'```.

#### UI Use

Open the Spectrum Settings. In the Main options section, clear the Full frequency span and change `Span` to `FStart`. Set FStart (Hz).

End of the frequency interval over which spectrum is computed, specified in hertz as a real scalar. 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 FrequencySpan to ```'Start and stop frequencies'```.

#### UI Use

Open the Spectrum Settings. In the Main options section, clear the Full frequency span and change `Span` to `FStart`. Set FStop (Hz).

Specify in hertz the center frequency of the span over which the Spectrum Analyzer computes and plots the spectrum. The overall frequency span, defined by the Span and this property, must fall within the Nyquist frequency interval.

Tunable: Yes

#### Dependency

To enable this property, set FrequencySpan to ```'Span and center frequency'```.

#### UI Use

Open the Spectrum Settings. In the Main, clear Full frequency span and set CF (Hz).

Specify the frequency span, in hertz, over which the Spectrum Analyzer computes and plots the spectrum. 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 FrequencySpan to ```'Span and center frequency'```.

#### UI Use

Open the Spectrum Settings. In the Main options section, clear the Full frequency span check box and set `Span`.

Specify the source for the time resolution of each spectrogram line as either `'Auto'` or `'Property'`. The TimeResolution property shows the time resolution for the different frequency resolution methods and time resolution properties.

Tunable: Yes

#### Dependency

To enable this property, set ViewType to `'Spectrogram'` or `'Spectrum and spectrogram'`.

#### UI Use

Open the Spectrum Settings. In the Spectrogram options section, set Time res (s).

Specify the time resolution of each spectrogram line as a positive scalar, expressed in seconds.

The time resolution value is determined based on frequency resolution method, the RBW setting, and the time resolution setting.

MethodFrequency Resolution MethodFrequency Resolution SettingTime Resolution SettingResulting Time Resolution in Seconds
`Welch` or `Filter Bank``RBW (Hz)``Auto``Auto`1/RBW
`Welch` or `Filter Bank``RBW (Hz)``Auto`Manually enteredTime Resolution
`Welch` or `Filter Bank``RBW (Hz)`Manually entered`Auto`1/RBW
`Welch` or `Filter Bank``RBW (Hz)`Manually enteredManually enteredMust be equal to or greater than the minimum attainable time resolution, 1/RBW. Several spectral estimates are combined into one spectrogram line to obtain the desired time resolution. Interpolation is used to obtain time resolution values that are not integer multiples of 1/RBW.
`Welch``Window length``Auto`1/RBW
`Welch``Window length`Manually enteredMust be equal to or greater than the minimum attainable time resolution. Several spectral estimates are combined into one spectrogram line to obtain the desired time resolution. Interpolation is used to obtain time resolution values that are not integer multiples of 1/RBW.
`Filter Bank``Number of frequency bands``Auto`1/RBW
`Filter Bank``Number of frequency bands`Manually enteredMust be equal to or greater than the minimum attainable time resolution, 1/RBW.

Tunable: Yes

#### Dependency

To enable this property, set:

#### UI Use

Open the Spectrum Settings. In the Spectrogram options section, in the Time res (s) box, enter a number.

Specify the source for the time span of the spectrogram as either `'Auto'` or `'Property'`. If you set this property to `'Auto'`, the spectrogram displays 100 spectrogram lines at any given time. If you set this property to `'Property'`, the spectrogram uses the time duration you specify in seconds in the TimeSpan property.

Tunable: Yes

#### Dependency

To enable this property, set ViewType to `'Spectrogram'` or `'Spectrum and spectrogram'`.

#### UI Use

Open the Spectrum Settings. In the Spectrogram options section, set Time span (s).

Specify the time span of the spectrogram display in seconds. 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'`.

#### UI Use

Open the Spectrum Settings. In the Spectrogram options section, in the Time span (s) box, enter a number.

The percentage overlap between the previous and current buffered data segments, specified as a real, scalar value. The overlap creates a window segment that is used to compute a spectral estimate. The value must be greater than or equal to zero and less than 100.

Tunable: Yes

#### UI Use

Open the Spectrum Settings. In the Window options section, set Overlap (%).

Specify a window function for the spectral estimator. The following table shows preset windows. For more information, follow the link to the corresponding function reference in the Signal Processing Toolbox™ documentation.

Window OptionCorresponding Signal Processing Toolbox Function
`'Rectangular'``rectwin`
`'Chebyshev'``chebwin`
`'Flat Top'``flattopwin`
`'Hamming'``hamming`
`'Hann'``hann`
`'Kaiser'``kaiser`
`'Blackman-Harris'``blackmanharris`

To set your own spectral estimation window, set this property to `'Custom'` and specify a custom window function in the CustomWindow property.

Tunable: Yes

#### UI Use

Open the Spectrum Settings. In the Window options section, set Window.

Specify a custom window function as a character array. The custom window function name must be on the MATLAB path. This property is useful if you want to customize the window using additional properties available with the Signal Processing Toolbox version of the window function.

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

#### UI Use

Open the Spectrum Settings. In the Window options section, in the Window option box, enter a custom window function name.

The window sidelobe attenuation, in decibels (dB). The value must be greater than or equal to `45`.

Tunable: Yes

#### Dependency

To enable this property, set Window to `'Chebyshev'` or `'Kaiser'`.

#### UI Use

Open the Spectrum Settings. In the Window options section, set Attenuation (dB).

Specify the units in which the Spectrum Analyzer displays power values.

Tunable: Yes

#### Dependency

The available spectrum units depends on the value of SpectrumType.

`SpectrumType`Allowed `SpectrumUnits`
`Power` or `Power density``'dBFS'`, `'dBm'`, `'dBW'`, `'Watts'`
`RMS``'Vrms'`, `'dBV'`

#### UI Use

Open the Spectrum Settings. In the Trace options section, set Units.

Specify the source of the dBFS scaling factor 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.

#### Dependency

To enable this property, set SpectrumUnits to `'dBFS'`.

#### UI Use

Open the Spectrum Settings. In the Trace options section, set Full scale to `Auto` or enter a number.

Specify a real positive scalar for the `dBFS` full scale.

Tunable: Yes

#### Dependency

To enable this option set:

#### UI Use

Open the Spectrum Settings. In the Trace options section, set Full scale to `Auto` or enter a number.

The load the scope uses as a reference to compute power levels.

Tunable: Yes

#### UI Use

Open the Spectrum Settings. In the Trace options section, set Reference load.

Set this property to `false` to remove the display of the normal traces. These traces display the free-running spectral estimates. Even when the traces are removed from the display, the Spectrum Analyzer continues its spectral computations.

Tunable: Yes

#### Dependency

To enable this property, set ViewType to `'Spectrum'` or `'Spectrum and spectrogram'`.

#### UI Use

Open the Spectrum Settings. In the Trace options section, select Normal trace.

To compute and plot the maximum-hold spectrum of each input channel, set this property to `true`. The maximum-hold spectrum at each frequency bin is computed by keeping the maximum value of all the power spectrum estimates. When you toggle 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'`.

#### UI Use

Open the Spectrum Settings. In the Trace options section, select Max-hold trace.

To compute and plot the minimum-hold spectrum of each input channel, set this property to `true`. The minimum-hold spectrum at each frequency bin is computed by keeping the minimum value of all the power spectrum estimates. When you toggle 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'`.

#### UI Use

Open the Spectrum Settings. In the Trace options section, select Min-hold trace.

Specify whether to display upper and lower spectral masks lines on a spectrum plot. This property uses `SpectralMaskSpecification` properties to enable and configure the spectral masks. The `SpectralMaskSpecification` properties are:

• `EnabledMasks` — Masks to enable, specified as a character vector. Valid values are `'None'`, `'Upper'`, `'Lower'`, or ```'Upper and lower'```.

Default: `'None'`

• `UpperMask` — Upper limit spectral mask, specified as a scalar or two-column matrix. If `UpperMask` is a scalar, the upper limit mask uses the power value of the scalar for all frequency values applicable to the Spectrum Analyzer. If `UpperMask` is a matrix, the first column contains the frequency values (Hz), which correspond to the x-axis values. The second column contains the power values, which correspond to the associated y-axis values. To apply offsets to the power and frequency values, use `ReferenceLevel` and `MaskFrequencyOffset` property values, respectively.

Default: `Inf`

• `LowerMask` — Lower limit spectral mask, specified as a scalar or two-column matrix. If `LowerMask` is a scalar, the lower limit mask uses the power value of the scalar for all frequency values applicable to the Spectrum Analyzer. If `LowerMask` is a matrix, the first column contains the frequency values (Hz), which correspond to the x-axis values. The second column contains the power values, which correspond to the associated y-axis values. To apply offsets to the power and frequency values, use `ReferenceLevel` and `MaskFrequencyOffset` property values, respectively.

Default: `-Inf`

• `ReferenceLevel` — Reference level for mask power values, specified as either `'Custom'` or `'Spectrum peak'`. When `ReferenceLevel` is `'Custom'`, the `CustomReferenceLevel` property value is used as the reference to the power values, in dBr, in the `UpperMask` and `LowerMask` properties. When `ReferenceLevel` is `'Spectrum peak'`, the peak value of the current spectrum of the `SelectedChannel` is used.

Default: `'Custom'`

• `CustomReferenceLevel` — Custom reference level, specified as a real value, in the same units as the power units. The reference level is the value to which to reference the power values in the `UpperMask` and `LowerMask` properties. This property applies when `ReferenceLevel` is set to `'Custom'`. This property uses the same units as the `PowerUnits` property of the Spectrum Analyzer.

Default: `0`

• `SelectedChannel` — Input channel with peak spectrum to use as the mask reference level, specified as an integer. This property applies when `ReferenceLevel` is set to ```'Spectrum peak'```.

Default: `1`

• `MaskFrequencyOffset` — Frequency offset, specified as a finite, numeric scalar. Frequency offset is the amount of offset to apply to frequency values in the `UpperMask` and `LowerMask` properties.

Default: `0`

All `SpectralMaskSpecification` properties are tunable.

Masks are overlaid on the spectrum. If the mask is green, the signal is passing. If the mask is red, the signal is failing.

You can check the status of the spectral mask using one of the following methods:

• To modify the spectral mask and see the spectral mask status, in the scope toolbar select the spectral mask button, . In the Spectral Mask panel that opens, you can modify the masks and see details about what percentage of the time the mask is succeeding, which mask is failing, how many times the mask failed, and which channels are causing the failure.

• To get the current status of the spectral masks, call the function `getSpectralMaskStatus`.

• To perform an action every time the mask fails, use the `MaskTestFailed` event. To trigger a function when the mask fails, create a listener to the `MaskTestFailed` event and define a callback function to trigger. For more details about using events, see Events (MATLAB).

Tunable: Yes

#### UI Use

Open the Spectral Mask panel and modify the Settings options.

### Visualization

Title of the scope window, specified as a character vector.

Tunable: Yes

Spectrum Analyzer window position in pixels, specified by the size and location of the scope window as a 4-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 to this property.

By default, the window appears in the center of your screen with a width of `800` pixels and height of `450` pixels. The exact center coordinates depend on your screen resolution.

Tunable: Yes

Specify the type of plot to use for displaying normal traces as either `'Line'` or `'Stem'`. Normal traces are traces that display free-running spectral estimates.

Tunable: Yes

#### Dependency

To enable this property, set:

• ViewType to `'Spectrum'` or `'Spectrum and spectrogram'`

• PlotNormalTrace to `true`

#### UI Use

Open the Style properties and set Plot type.

The simulation speed is faster when this property is set to `true`.

• `true` - the scope logs data for later use and updates the display at fixed intervals of time. Data occurring between these fixed intervals might not be plotted.

• `false` - the scope updates every time it computes the power spectrum. Use the `false` setting when you do not want to miss any spectral updates at the expense of slower simulation speed.

Tunable: Yes

#### UI Use

Select Playback > Reduce plot rate to improve performance.

Specify the display title as a character vector or string. Enter `%<SignalLabel>` to use the signal labels as the axes titles.

Tunable: Yes

#### UI Use

Open the Configuration Properties. On the Display tab, set Title.

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

From the legend, you can control which signals are visible. This control is equivalent to changing the visibility in the Style dialog box. 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

#### UI Use

Open the Configuration Properties. On the Display tab, select Show legend.

Specify the input channel names as a cell array of character vectors or strings. The names appear in the legend, Style dialog box, and Measurements panels. If you do not specify names, the channels are labeled as `Channel 1`, `Channel 2`, etc.

Tunable: Yes

#### Dependency

To see channel names, set `ShowLegend` to `true`.

#### UI Use

Show the legend and double-click the channel name.

Set this property to `true` to show gridlines on the plot.

Tunable: Yes

#### UI Use

Open the Configuration Properties. On the Display tab, set Show grid.

Specify the y-axis limits as a 2-element numeric vector, `[ymin ymax]`.

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

Tunable: Yes

#### Dependencies

• To enable this property,set the ViewType property to `'Spectrum'` or `'Spectrum and spectrogram'`.

• The units directly depend upon the SpectrumUnits property.

#### UI Use

Open the Configuration Properties. Set Y-limits (maximum) and Y-limits (minimum).

Control the color limits of the spectogram using a 2-element numeric vector, ```[colorMin colorMax]```.

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

#### Dependencies

• To enable this property,set the ViewType property to `'Spectrogram'` or `'Spectrum and spectrogram'`.

• The units directly depend upon the `SpectrumUnits` property.

#### UI Use

Open the Configuration Properties. Set Color-limits (minimum) and Color-limits (maximum).

Specify the text for the scope to display 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'`.

#### UI Use

Open the Configuration Properties. Set Y-label.

Specify the layout type as `'Horizontal'` or `'Vertical'`. A vertical layout stacks the spectrum above the spectrogram. A horizontal layout puts the two views side-by-side.

Tunable: Yes

#### Dependency

To enable this property, set ViewType to ```'Spectrum and spectrogram'```.

#### UI Use

Open the Spectrum Settings. Set Axes layout.

## Usage

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.

### Syntax

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

### Description

````scope(signal)` updates the spectrum of the signal in the spectrum analyzer.`scope(signal1,signal2,...,signalN)` displays multiple signals in the spectrum analyzer. The signals must have the same frame length, but can vary in number of channels. You must set the `NumInputPorts` property to enable multiple input signals. ```

### Input Arguments

expand all

Specify one or more input signals to visualize in the `dsp.SpectrumAnalyzer`. Signals can have a different number of channels, but must have the same frame length.

Example: `scope(signal1, signal2)`

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64` | `logical` | `char` | `string` | `struct` | `table` | `cell` | `categorical` | `datetime` | `fi`

## 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)`
 `getSpectralMaskStatus` Get test results of current spectral mask `getSpectrumData` Save spectrum data shown in spectrum analyzer `isNewDataReady` Check spectrum analyzer for new data
 `show` Display scope window `hide` Hide scope window
 `step` Run System object algorithm `clone` Create duplicate System object `getNumInputs` Number of inputs required to call the System object `getNumOutputs` Number of outputs from calling the System object `isLocked` Determine if System object is locked `release` Release resources and allow changes to System object property values and input characteristics `reset` Reset internal states of System object

## Examples

expand all

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

```Fs = 100e6; % Sampling frequency 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 = dsp.SpectrumAnalyzer; scope.SampleRate = Fs; scope.SpectralAverages = 1; scope.PlotAsTwoSidedSpectrum = false; scope.RBWSource = 'Auto'; scope.PowerUnits = 'dBW'; for idx = 1:1e2 y1 = sin1(); y2 = sin2(); y3 = sin3(); y4 = sin4(); y5 = sin5(); scope(y1+y2+y3+y4+y5+0.0001*randn(fSz,1)); end ```

Run the `release` method 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'); ```

This example shows 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 = dsp.SpectrumAnalyzer('SampleRate',Fs); scope.SpectrumType = 'Spectrogram'; scope.RBWSource = 'Property'; scope.RBW = 500; scope.TimeSpanSource = 'Property'; scope.TimeSpan = 2; scope.PlotAsTwoSidedSpectrum = false; for idx = 1:50 y = chirp()+ 0.05*randn(frameSize,1); scope(y); end release(scope) ```

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

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

Run the `release` method to change property values and input characteristics. The scope automatically scales the axes. It updates the display one more time if any data is in the internal buffer.

```release(scope); ```

Run the MATLAB `clear` function to close the Spectrum Analyzer window.

```clear('scope'); ```

## Tips

• To close the scope window and clear its associated data, use the MATLAB® `clear` function.

• To hide or show the scope window, use the `hide` and `show` functions.

• Use the MATLAB `mcc` function to compile code containing a Spectrum Analyzer.

You cannot open Spectrum Analyzer configuration dialogs if you have more than one compiled component in your application.

expand all