Configure Spectrum Analyzer

Use the Spectrum Analyzer to visualize frequency. You can customize the spectrum
analyzer display to show the data and measurement information needed.

Signal and Spectrum Computation Information

The Spectrum Analyzer shows the spectrum computation settings for the current
visualization. In the scope status bar, check the Resolution
Bandwidth, Time Resolution, and
Offset indicators for this information. The values
specified by these indicators can change depending on your settings in the
Spectrum Settings panel. You can also view the simulation
status and the amount of time data that correspond to the current display. Check the
Simulation status and Display time
indicators for this information.

Resolution Bandwidth — The smallest positive frequency or frequency interval
that can be resolved.

Spectrum Analyzer sets the resolution bandwidth based on the
FrequencyResolutionMethod property setting on the Main
options pane of the Spectrum Settings panel. If
FrequencyResolutionMethod is RBW (Hz) then the
specified value of RBW is used. You can also get or set this value from the RBW property when RBWSource is set to
'Property'. By default, the RBW (Hz) parameter on the
Main options pane and the related RBWSource property are set
to 'Auto'. In this case, the Spectrum Analyzer determines the appropriate value to
ensure that there are 1024 RBW intervals over the specified Frequency Span.

You can set the resolution bandwidth to whatever value you choose. For
this reason, there is a minimum boundary on the number of input samples
required to compute a spectral update. This number of input samples
required to compute one spectral update is shown as
Samples/update in the Main
options pane. This value is directly related to
RBW by the following equation:

Nsamples=(1−Op100)×NENBW×FsRBW

Overlap percentage,
Op, is the value of
the Overlap % parameter in the Window
Options pane of the Spectrum
Settings panel. NENBW is the
normalized effective noise bandwidth, a factor of the windowing method
used, which is shown in the Window Options pane.
Fs is the sample rate.
In some cases, the number of samples provided in the input are not
sufficient to achieve the resolution bandwidth that you specify. When
this situation occurs, Spectrum Analyzer shows a warning message on the display.

Spectrum Analyzer removes this message and displays a
spectral estimate when enough data has been input.

If the FrequencyResolutionMethod property setting on the
Main options pane of the Spectrum Settings is
Window length, you specify the window length and the resulting RBW is

NENBW×FsNwindow

The Samples/update in this case is directly related to
RBW by the following equation:

Time resolution is the amount of data, in seconds, used to compute a
spectrogram line. The Time Resolution parameter is available only when the
spectrum View is Spectrogram. The minimum
attainable resolution is the amount of data time required to compute a single spectral
estimate. When the SpectrumType
property is set to 'Spectrogram', you can get or set the minimum attainable
resolution value from the TimeResolution property. See
the time resolution table in the TimeResolution property description.

Offset — The constant frequency offset to apply to the entire spectrum or a
vector of frequency offsets to apply to each spectrum for multiple inputs.

Spectrum Analyzer adds this constant offset or the vector of offsets to the values on the
frequency-axis using the value of Offset on the
Trace options pane of the Spectrum Settings panel. You can
also set the offset from the FrequencyOffset property. The
offset is the current time value at the middle of the interval of the line displayed at 0 seconds. The
actual time of a particular spectrogram line is the offset minus the y-axis time
listing. The offset is displayed on the plot only when the spectrum View is
Spectrogram.

Every time you call the scope, the simulation time increases by the number of rows in the input
signal divided by the sample rate, as given by the following formula:

tsim=tsim−1+length(0:length(xsine))−1SampleRate

. At the beginning of a simulation, you can modify the
SampleRate parameter on the Main options pane of the
Spectrum Settings panel. You can also set the sample rate using the SampleRate property. The
display time is updated each time the display is updated. When ReducePlotRate is
true, the simulation time and display time might differ. If at the end of a for
loop that includes the Spectrum Analyzer, the times differ, you can call the
release method to update the display with any data left in the buffer. Note,
however, that if the remaining data is not a complete window interval, the display is not
updated.

The Display time indicator is a component of the
status bar in the Spectrum Analyzer window. You can choose to hide or
display the entire status bar. From the Spectrum Analyzer menu, select View > Status Bar .

Frequency span — The range of values shown on the
frequency-axis on the Spectrum Analyzer window.

Spectrum Analyzer sets the frequency span using the values of parameters on the Main
options pane of the Spectrum Settings panel.

Span(Hz) and CF(Hz) visible — The
Frequency span value equals the Span parameter in
the Main options pane. You can also get or set this value from the
Span property when the
FrequencySpan property is set to 'Span and Center Frequency'.

FStart(Hz) and FStop(Hz) — The
Frequency span value equals the difference of the
FStop and FStart parameters in the Main
options pane, as given by the formula: fspan=fstop−fstart. You can also get or set these values from the StartFrequency and
StopFrequency
properties when the FrequencySpan property is set to 'Start and
stop frequencies'.

By default, the Full Span check box in the Main options
pane is enabled, and its equivalent FrequencySpan property is set to
'Full'. In this case, the Spectrum Analyzer computes and plots the spectrum over
the entire Nyquist frequency interval. When the Two-sided
spectrum check box in the Trace options pane is enabled, and its
equivalent PlotAsTwoSidedSpectrum property is true, the Nyquist interval is, in hertz:

[−SampleRate2,SampleRate2]+FrequencyOffset

If you set the PlotAsTwoSidedSpectrum property to
false, the Nyquist interval is in hertz:

[0,SampleRate2]+FrequencyOffset

Reduce Plot Rate to Improve Performance

By default, Spectrum Analyzer updates the display at fixed intervals of time at a rate not exceeding 20
hertz. If you want Spectrum Analyzer to plot a spectrum on every simulation time step, you can disable the Simulation > Reduce Plot Rate to Improve Performance option.

Note

When this option is selected, the Spectrum Analyzer may display a misleading spectrum in some
situations. For example, if the input signal is wide-band with non-stationary behavior, such as a chirp
signal, Spectrum Analyzer might display a stationary spectrum. The reason for this behavior is that
Spectrum Analyzer buffers the input signal data and only updates the display periodically at approximately
20 times per second. Therefore, Spectrum Analyzer does not render changes to the spectrum that occur and
elapse between updates, which gives the impression of an incorrect spectrum. To ensure that spectral
estimates are as accurate as possible, clear the Reduce Plot Rate to Improve
Performance check box. When you clear this box, Spectrum Analyzer calculates spectra whenever
there is enough data, rendering results correctly.

Generate a MATLAB Script

You can change Spectrum Analyzer settings using menus and options in the interface of the scope, or by changing properties at the command line. If you change settings in the dsp.SpectrumAnalyzer interface, you can generate the corresponding command line settings to use later.

Note

The script only generates commands for settings that are available from the command line, applicable to the current visualization, and changed from the default value.

This example shows how to generate a script after making changes to the dsp.SpectrumAnalyzer in the interface:

Create a dsp.SpectrumAnalyzer System object.

scope = dsp.SpectrumAnalyzer();
show(scope);

Set options in the Spectrum Analyzer. For this example, turn on the Cursor Measurements. Also in the Spectrum Settings, change the View type to Spectrum and spectrogram and set the Axes Layout to Horizontal.

Generate a script to recreate the dsp.SpectrumAnalyzer with the same
modified settings. Either select File > Generate MATLAB Script or
enter:

Check Spectral Masks

You can check the status of the spectral mask in several different ways:

In the Spectrum Analyzer window, select the spectral mask button, . In the Spectral Mask pane, the
Statistics section shows statistics about how often the masks
fail, which channels have caused a failure, and which masks are currently
failing.

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

Spectral Mask in Spectrum Analyzer Block

This example shows how to create a new model based on the dsp_basic_filter template, add a spectral mask to its Spectrum Analyzer block, and run the model.

Masks are overlaid on the spectrum. If the mask is green, the signal is passing. If the mask is red, the signal is failing. The Spectral Mask panel shows what percentage of the time the mask is succeeding, which mask is failing, how many times the mask(s) failed, and which channels are causing the failure.

Measurements Panels

The Measurements panels are the panels that appear on the right side of the Spectrum Analyzer. These
measurements allow you to interact with the frequency values.

Trace Selection Panel

When you use the scope to view multiple signals, the Trace Selection panel appears. Use this panel to select which signal to
measure. To open the Trace Selection panel:

From the menu, select Tools > Measurements > Trace Selection.

Open a measurement panel.

Cursor Measurements Panel

The Cursor Measurements panel displays screen cursors. The panel provides two types of
cursors for measuring signals. Waveform cursors are vertical cursors that track along the signal. Screen cursors are both
horizontal and vertical cursors that you can place anywhere in the display.

Note

If a data point in your signal has more than one value, the cursor measurement at that point is undefined and no
cursor value is displayed.

Lock Cursor Spacing — Locks the frequency difference between the two cursors.

Snap to Data — Positions the cursors on signal data points.

The Measurements pane displays the frequency (Hz) , time (s),
and power (dBm) value measurements. Time is displayed only in spectrogram
mode. Channel Power shows the total power between the cursors.

1 — Shows or enables you to modify the frequency, time (for spectrograms only), or both, at cursor number one.

2 — Shows or enables you to modify the frequency, time (for spectrograms only), or both, at cursor number two.

Δ — Shows the absolute value of the difference in the frequency, time (for spectrograms only), or both, and power between cursor number one
and cursor number two.

Channel Power — Shows the total power in the channel defined by the cursors.

The letter after the value associated with a measurement indicates the abbreviation for the appropriate International
System of Units (SI) prefix.

Peak Finder Panel

The Peak Finder panel displays the maxima, showing the x-axis values
at which they occur. Peaks are defined as a local maximum where lower values are present on both sides of a peak.
Endpoints are not considered peaks. This panel allows you to modify the settings for peak threshold, maximum number of
peaks, and peak excursion.

From the menu, select Tools > Measurements > Peak Finder.

On the toolbar, click the Peak Finder button.

The Settings pane enables you to modify the parameters used to calculate the peak values within the
displayed portion of the input signal. For more information on the algorithms this pane uses, see the findpeaks function reference.

Properties to set:

Peak Threshold — The level above which peaks are detected. This setting is equivalent to
the MINPEAKHEIGHT parameter, which you can set when you run the findpeaks
function.

Max Num of Peaks — The maximum number of peaks to show. The value you enter must be a
scalar integer from 1 through 99. This setting is equivalent to the NPEAKS parameter, which you
can set when you run the findpeaks function.

Min Peaks Distance — The minimum number of samples between adjacent peaks. This setting is
equivalent to the MINPEAKDISTANCE parameter, which you can set when you run the
findpeaks function.

Peak Excursion — The minimum height difference between a peak and its neighboring samples.
Peak excursion is illustrated alongside peak threshold in the following figure.

The peak threshold is a minimum value necessary for a sample value to be a
peak. The peak excursion is the minimum difference between a peak sample and the samples to
its left and right in the time domain. In the figure, the green vertical line illustrates the lesser of the two
height differences between the labeled peak and its neighboring samples. This height difference must be greater
than the Peak Excursion value for the labeled peak to be classified as a peak. Compare this
setting to peak threshold, which is illustrated by the red horizontal line. The amplitude must be above this
horizontal line for the labeled peak to be classified as a peak.

The peak excursion setting is equivalent to the THRESHOLD parameter, which you can set when
you run the findpeaks function.

Label Format — The coordinates to display next to the calculated peak values on the plot.
To see peak values, you must first expand the Peaks pane and select the check boxes
associated with individual peaks of interest. By default, both x-axis and
y-axis values are displayed on the plot. Select which axes values you want to display next to
each peak symbol on the display.

X+Y — Display both x-axis and y-axis
values.

X — Display only x-axis values.

Y — Display only y-axis values.

The Peaks pane displays the largest calculated peak values. It also shows the coordinates at which
the peaks occur, using the parameters you define in the Settings pane. You set the Max Num
of Peaks parameter to specify the number of peaks shown in the list.

The numerical values displayed in the Value column are equivalent to the pks
output argument returned when you run the findpeaks function. The numerical values displayed in the
second column are similar to the locs output argument returned when you run the
findpeaks function.

The Peak Finder displays the peak values in the Peaks pane. By default, the Peak
Finder panel displays the largest calculated peak values in the Peaks pane in decreasing
order of peak height.

Use the check boxes to control which peak values are shown on the display. By default, all check boxes are cleared and
the Peak Finder panel hides all the peak values. To show or hide all the peak values on the display,
use the check box in the top-left corner of the Peaks pane.

The Peaks are valid for any units of the input signal. The letter after the value associated with each measurement
indicates the abbreviation for the appropriate International System of Units (SI) prefix, such as m
for milli-. For example, if the input signal is measured in volts, an m next to
a measurement value indicates that this value is in units of millivolts.

In addition to the measurements, the Channel Measurements panel
has an expandable Channel Settings pane.

Measurement — The type of measurement data to display. Available options are
Occupied BW or ACPR. See Algorithms for information on how
Occupied BW is calculated. ACPR is the adjacent channel power ratio, which is the ratio of the main channel power
to the adjacent channel power.

When you select Occupied BW as the Measurement, the
following fields appear.

Select the frequency span of the channel, Span(Hz), and specify the
center frequency CF (Hz) of the channel. Alternatively, select the starting
frequency, FStart(Hz), and specify the starting frequency and ending
frequency (FStop (Hz)) values of the channel.

CF (Hz) — The center frequency of the channel.

Occupied BW (%) — The percentage of the total integrated power of the
spectrum centered on the selected channel frequency over which to compute the occupied bandwidth.

Channel Power — The total power in the channel.

Occupied BW — The bandwidth containing the specified Occupied BW (%)
of the total power of the spectrum. This setting is available only if you select Occupied
BW as the Measurement type.

Frequency Error — The difference between the center of the occupied band and the
center frequency (CF) of the channel. This setting is available only if you select
Occupied BW as the Measurement type.

When you select ACPR as the Measurement, the following
fields appear.

Channel Settings — Enables you to modify the parameters for calculating the channel
measurements.

Select the frequency span of the channel, Span (Hz), and specify the
center frequency CF (Hz) of the channel. Alternatively, select the starting
frequency, FStart(Hz), and specify the starting frequency and ending
frequency (FStop (Hz)) values of the channel.

CF (Hz) — The center frequency of the channel.

Number of Pairs — The number of pairs of adjacent channels.

Bandwidth (Hz) — The bandwidth of the adjacent channels.

Filter — The filter to use for both main and adjacent channels.
Available filters are None, Gaussian, and
RRC (root-raised cosine).

Channel Power — The total power in the channel.

Offset (Hz) — The center frequency of the adjacent channel with respect to the
center frequency of the main channel. This setting is available only if you select ACPR
as the Measurement type.

Lower (dBc) — The power ratio of the lower sideband to the main channel. This
setting is available only if you select ACPR as the Measurement
type.

Upper (dBc) — The power ratio of the upper sideband to the main channel. This
setting is available only if you select ACPR as the Measurement
type.

The Distortion Measurements panel has an expandable Harmonics pane, which
shows measurement results for the specified number of harmonics.

Note

For an accurate measurement, ensure that the fundamental signal (for harmonics) or primary tones (for
intermodulation) is larger than any spurious or harmonic content. To do so, you may need to adjust the
resolution bandwidth (RBW) of the spectrum analyzer. Make sure that the bandwidth is
low enough to isolate the signal and harmonics from spurious and noise content. In general, you should set
the RBW so that there is at least a 10dB separation between the peaks of the sinusoids and the noise
floor. You may also need to select a different spectral window to obtain a valid measurement.

Distortion — The type of distortion measurements to display. Available
options are Harmonic or Intermodulation.
Select Harmonic if your system input is a single sinusoid. Select
Intermodulation if your system input is two equal amplitude sinusoids.
Intermodulation can help you determine distortion when only a small portion of the available
bandwidth will be used.

When you select Harmonic as the Distortion, the
following fields appear.

The harmonic distortion measurement automatically locates the largest sinusoidal component
(fundamental signal frequency). It then computes the harmonic frequencies and power in each harmonic in your
signal. Any DC component is ignored. Any harmonics that are outside the spectrum analyzer’s frequency span are not
included in the measurements. Adjust your frequency span so that it includes all the desired harmonics.

Note

To view the best harmonics, make sure that your fundamental frequency is set high enough to resolve the
harmonics. However, this frequency should not be so high that aliasing occurs. For the best display of
harmonic distortion, your plot should not show skirts, which indicate frequency leakage. Also, the noise
floor should be visible.

For a better display, try a Kaiser window with a large sidelobe attenuation (e.g. between 100–300
db).

Num. Harmonics — Number of harmonics to display, including the
fundamental frequency. Valid values of Num. Harmonics are from
2 to 99. The default value is
6.

1 — The fundamental frequency, in hertz, and its power, in decibels of
the measured power referenced to 1 milliwatt (dBm).

2, 3, ... — The harmonics frequencies, in hertz, and their power in
decibels relative to the carrier (dBc). If the harmonics are at the same level or exceed the
fundamental frequency, reduce the input power.

THD — The total harmonic distortion. This value represents the ratio of
the power in the harmonics, D, to the power in the fundamental frequency,
S. If the noise power is too high in relation to the harmonics, the THD value
is not accurate. In this case, lower the resolution bandwidth or select a different spectral
window.

THD=10⋅log10(D/S)

SNR — Signal-to-noise ratio (SNR). This value represents the ratio of
power in the fundamental frequency, S, to the power of all nonharmonic content,
N, including spurious signals, in decibels relative to the carrier (dBc).

SNR=10⋅log10(S/N)

If you see –– as the reported SNR, the total non-harmonic
content of your signal is less than 30% of the total signal.

SINAD — Signal-to-noise-and-distortion. This value represents the ratio
of the power in the fundamental frequency, S to all other content (including
noise, N, and harmonic distortion, D), in decibels relative
to the carrier (dBc).

SINAD=10⋅log10(SN+D)

SFDR — Spurious free dynamic range (SFDR). This value represents the
ratio of the power in the fundamental frequency, S, to power of the largest
spurious signal, R, regardless of where it falls in the frequency spectrum. The
worst spurious signal may or may not be a harmonic of the original signal. SFDR represents the
smallest value of a signal that can be distinguished from a large interfering signal. SFDR
includes harmonics.

SNR=10⋅log10(S/R)

When you select Intermodulation as the Distortion,
the following fields appear.

The intermodulation distortion measurement automatically locates the fundamental, first-order
frequencies (F1 and F2). It then computes the frequencies of the third-order intermodulation products (2*F1-F2 and
2*F2-F1).

TOI — Third-order intercept point. If the noise power is too high in
relation to the harmonics, the TOI value will not be accurate. In this case, you should lower the
resolution bandwidth or select a different spectral window. If the TOI has the same amplitude as
the input two-tone signal, reduce the power of that input signal.

CCDF Measurements Panel

The CCDF Measurements panel
displays complimentary cumulative distribution function measurements.
CCDF measurements in this scope show the probability of a signal’s
instantaneous power being a specified level above the signal’s
average power. These measurements are useful indicators of a signal’s
dynamic range.

To compute the CCDF measurements, each input sample is quantized
to 0.01 dB increments. Using a histogram 100 dB wide (10,000 points
at 0.01 dB increments), the largest peak encountered is placed in
the last bin of the histogram. If a new peak is encountered, the histogram
shifts to make room for that new peak.

Probability (%) — The
percentage of the signal that contains the power level above the value
listed in the dB above average column

dB above average — The
expected minimum power level at the associated Probability
(%).

Average Power — The average
power level of the signal since the start of simulation or from the
last reset.

Max Power — The maximum power level
of the signal since the start of simulation or from the last reset.

PAPR — The ratio of the
peak power to the average power of the signal. PAPR should be less
that 100 dB to obtain accurate CCDF measurements. If PAPR is above
100 dB, only the highest 100 dB power levels are plotted in the display
and shown in the distribution table.

Sample Count — The total
number of samples used to compute the CCDF.

Reset — Clear all current
CCDF measurements and restart.

Customize Visualization

To control the labels, minimum and maximum values, the legend, and gridlines, use
the configuration properties. From the Spectrum Analyzer, select View > Configuration Properties or click the toolbar button .

In the Style dialog box, you can customize the style of
spectrum display. This dialog box is not
available for the spectrogram view. You can change the color of the
spectrum plot, color of the background, and properties of the lines. To open this
dialog box, select View > Style.

If you are viewing only the spectrum or the spectrogram, you only see the relevant
options. For more details about these options, see Configuration Properties and Style.

Zoom and Pan

To zoom in and out of the plot, or pan to different area of the plot, use the zoom
buttons in the toolbar or in the Tools menu.

You can set properties to zoom in/out automatically or scale the axes. In the
Spectrum Analyzer menu, select Tools > Axes Scaling.

If you are viewing only the spectrum or the
spectrogram, you see only the relevant options. If you are using the CCDF
measurements, you will also see x-axis scaling options. For more
details about these options, see Axes Scaling.

Open Example

A modified version of this example exists on your system. Do you want to open this version instead?

This website uses cookies to improve your user experience, personalize content and ads, and analyze website traffic. By continuing to use this website, you consent to our use of cookies. Please see our Privacy Policy to learn more about cookies and how to change your settings.