Display frequency spectrum
DSP System Toolbox / Sinks
DSP System Toolbox HDL Support / Sinks
The Spectrum Analyzer block, referred to here as the scope, displays the frequency spectra of signals.
You can use the Spectrum Analyzer block in models running in Normal or Accelerator simulation modes. You can also use the Spectrum Analyzer block in models running in Rapid Accelerator or External simulation modes, with some limitations.
You can use the Spectrum Analyzer block inside all subsystems and conditional subsystems. Conditional subsystems include enabled subsystems, triggered subsystems, enabled and triggered subsystems, and functioncall subsystems. See Conditionally Executed Subsystems Overview (Simulink) for more information.
Cursors — Measure signal values using vertical and horizontal cursors.
Peak Finder — Find maxima, showing the xaxis values at which they occur.
Channel Measurements — Measure the occupied bandwidth or adjacent channel power ratio (ACPR).
Distortion Measurements — Measure harmonic distortion and intermodulation distortion.
CCDF Measurements — Measure the complimentary cumulative distribution function. CCDF measurements show the probability of a signal’s instantaneous power being a specified level above the signal’s average power.
Spectral Masks — Visualize spectrum limits and compare spectrum values to specification values.
You can configure and display Spectrum Analyzer settings from the command line
with the SpectrumAnalyzerConfiguration
object.
Port_1
— Signals to visualizeConnect the signals you want to visualize. You can have up to 96 input ports. Input signals can have these characteristics:
Signal Domain — Frequency or time signals
Type — Discrete (samplebased and framebased).
Data type — Any data type that Simulink^{®} supports. See Data Types Supported by Simulink (Simulink).
Dimension — One dimensional (vector), two dimensional (matrix), or multidimensional (array). Input must have fixed number of channels. See Signal Dimensions (Simulink) and Determine Signal Dimensions (Simulink).
Data Types: single
 double
 int8
 int16
 int32
 int64
 uint8
 uint16
 uint32
 uint64
 fixed point
Complex Number Support: Yes
The Spectrum Settings pane appears at the right side of the Spectrum Analyzer window. These settings control how the spectrum is calculated. To show the Spectrum Settings, in the Spectrum Analyzer menu, select View > Spectrum Settings or use the button in the toolbar.
Main optionsInput domain
— Domain of the input signalTime
(default)  Frequency
The domain of the input signal you want to visualize. If you visualize
timedomain signals, the signal is transformed to the frequency spectrum
based on the algorithm specified by the Method
parameter.
See InputDomain
.
Type
— Type of spectrum to displayPower
(default)  Power density
 RMS
Power
— Spectrum Analyzer shows the power spectrum.
Power density
— Spectrum Analyzer shows the power spectral density.
The power spectral density is the magnitude of the spectrum normalized to a bandwidth of
1 hertz.
RMS
— Spectrum Analyzer shows the root mean squared
spectrum.
Tunable: Yes
To use this parameter, set Input domain to Time
.
See SpectrumType
.
View
— Spectrum viewSpectrum
(default)  Spectrogram
 Spectrum and spectrogram
Spectrum
— Spectrum Analyzer shows the
spectrum.
Spectrogram
— Spectrum Analyzer shows the
spectrogram, which displays frequency content over time. The most recent
spectrogram update is at the bottom of the display, and time scrolls
from the bottom to the top of the display.
Spectrum and spectrogram
— Spectrum Analyzer
shows both the spectrum and spectrogram.
Tunable: Yes
See ViewType
.
Sample rate
— Sample rate of the input signal in hertzInherited
(default)  positive scalarSample rate of the input signal in hertz, specified as either
Inherited
to use the same sample rate as the
input signal.
Positive scalar. The specified sample rate must be at least twice the input signal sample rate. Otherwise, you might see unexpected behavior in your signal visualization due to aliasing.
See SampleRate.
Method
— Spectrum estimation methodFilter Bank
(default)  Welch
Select Welch
or Filter
Bank
as the spectrum estimation method. For more
details about the two spectrum estimation algorithms, see Algorithms.
Tunable: No
To use this parameter, set Input domain
to Time
.
See Method
.
Full frequency span
— Use entire Nyquist frequency intervalSelect this check box to compute and plot the spectrum over the entire Nyquist frequency interval.
Tunable: Yes
To use this parameter, set Input domain
to Time
.
See FrequencySpan
.
Span (Hz)
— Frequency span in hertz 10e3
(default)  real positive scalarSpecify the frequency span in hertz. Use this parameter with the
CF
(Hz)
parameter to define the frequency span around a
center frequency. This parameter defines the range of values shown on
the Frequency axis in the Spectrum Analyzer window.
Tunable: Yes
To use this parameter, you must:
Set Input domain to Time
.
Clear the Full frequency span check box.
Set the Span (Hz)/Fstart (Hz)
dropdown to Span
(Hz)
.
See FrequencySpan
and Span
.
CF (Hz)
— Center frequency in hertz0
(default)  scalarSpecify the center frequency, in hertz. Use this parameter with the Span (Hz) parameter to define the frequency span around a center frequency. This parameter defines the value shown at the middle point of the Frequency axis on the Spectrum Analyzer window.
Tunable: Yes
To use this parameter, you must:
Set Input domain to Time
.
Clear the Full frequency span check box.
Set the Span (Hz)/Fstart (Hz) dropdown to Span (Hz).
See CenterFrequency
.
FStart (Hz)
— Start frequency in hertz5e3
(default)  scalarSpecify the start frequency in hertz. Use this parameter with the FStop (Hz) parameter to define the range of frequencyaxis values using start frequency and stop frequency. This parameter defines the value shown at the leftmost side of the Frequency axis on the Spectrum Analyzer window.
Tunable: Yes
To use this parameter, you must:
Set Input domain to Time
.
Clear the Full frequency span check box.
Set the Span (Hz)/FStart (Hz)
dropdown to FStart
(Hz)
.
See StartFrequency
.
FStop (Hz)
— Stop frequency in hertz5e3
(default)  scalarSpecify the stop frequency, in hertz. Use this parameter with the FStart (Hz) parameter to define the range of Frequency axis values. This parameter defines the value shown at the rightmost side of the Frequency axis on the Spectrum Analyzer window.
Tunable: Yes
To use this parameter, you must:
Set Input domain to Time
.
Clear the Full frequency span check box.
Set the Span (Hz)/FStart (Hz) dropdown to FStart (Hz).
See StopFrequency
.
Frequency (Hz)
— Frequency vectorAuto
(default)  Input port
 monotonically increasing vectorSet the frequency vector which determines the xaxis of the display.
Auto
— The frequency vector is
calculated from the length of the input. See Frequency Vector.
Input port
— When selected, an
input port appears on the block for the frequency vector
input.
Custom vector — Enter a custom vector as the frequency vector. The length of the custom vector must be equal to the frame size of the input signal.
Tunable: No
To use this parameter, set Input domain
to Frequency
.
See FrequencyVector
.
RBW (Hz)
— Resolution bandwidthAuto
(default)  Input port
 positive scalarThe resolution bandwidth in hertz. This parameter defines the smallest
positive frequency that can be resolved. By default, this parameter is
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.
If you set this parameter to a numeric value, the value must allow at least two RBW intervals over the specified frequency span. In other words, the ratio of the overall frequency span to RBW must be greater than two:
$$\frac{span}{RBW}>2$$
For frequency input only, you can use an input port to set the RBW value.
Tunable: Yes
To use this parameter, set either:
Input domain to Time
and the
RBW (Hz)/Window length/Number of frequency
bands dropdown to RBW
(Hz)
.
Input domain to Frequency
.
See RBW
.
Input units
— Units of frequency inputAuto
(default)  dBm
 dBV
 dBW
 Vrms
 Watts
Select the units of the frequencydomain input. This property allows the Spectrum Analyzer to scale frequency data if you choose a different display unit with the Units property.
Tunable: No
This option is only available when Input domain
is set to Frequency
.
See InputUnits
.
Window length
— Length of window in samples1024
(default)  integer greater than 2The length of the window, in samples. The window length used to control the frequency resolution and compute the spectral estimates. The window length must be an integer greater than 2.
To use this parameter, set:
Method to Welch
Set the RBW (Hz)/Window length/Number of
frequency bands dropdown to
Window Length
To use this parameter, set Input domain
to Time
.
See WindowLength
.
Number of frequency bands
— FFT lengthAuto
(default)  positive integerSpecify the fast Fourier transform (FFT) length to control the number
of frequency bands. If the value is Auto
, the
Spectrum Analyzer uses the entire frame size to estimate the spectrum.
If you specify the number of frequency bands, you set the input buffer
size.
To use this parameter, set:
Method to Filter Bank
Set the RBW (Hz)/Window length/Number of
frequency bands dropdown to
Number of frequency
bands
See FFTLength
Taps per band
— Number of filter taps12
(default)  positive even integerSpecify the number of filter taps or coefficients for each frequency band. This number must be a positive even integer. This value corresponds to the number of filter coefficients per polyphase branch. The total number of filter coefficients is equal to Taps Per Band + FFT Length.
To use this parameter, you must set the RBW (Hz)/Window length/Number of frequency bands dropdown to Number of frequency bands.
See NumTapsPerBand
.
NFFT
— Number of FFT pointsAuto
(default)  positive integerSpecify the length of the FFT that Spectrum Analyzer uses to compute
spectral estimates. Acceptable options are
Auto
or a positive integer.
The NFFT value must be greater than or equal to
the value of the Window length parameter. By
default, when NFFT is set to
Auto
, the Spectrum Analyzer sets
NFFT equal to the value of Window
length. When in RBW mode, the specified RBW value is used
to calculate an FFT length that equals the window length.
When this parameter is set to a positive integer, this parameter is
equivalent to the n
parameter of the fft
function.
To use this parameter, you must set the RBW (Hz)/Window length/Number of frequency bands dropdown to Window length.
See FFTLength
.
Samples/update
— Required number of input samplesThis property is readonly.
The number of input samples required to compute one spectral update. You cannot modify this parameter; it is shown in the spectrum analyzer for informational purposes only. This parameter is directly related to RBW (Hz)/Window length/Number of frequency bands. For more details, see Algorithms.
If the input does not have enough samples to achieve the resolution bandwidth that you specify, Spectrum Analyzer produces a message on the display.
Channel
— Spectrogram channelSelect the signal channel for which the spectrogram settings apply.
To use this option, set View
to Spectrogram
or Spectrum
and spectrogram
.
See SpectrogramChannel
.
Time res. (s)
— Time resolution in secondsAuto
(default)  positive numberTime resolution is the amount of data, in seconds, used to compute a spectrogram line. The minimum attainable resolution is the amount of time it takes to compute a single spectral estimate. The tooltip displays the minimum attainable resolution given the current settings.
The time resolution value is determined based on frequency resolution method, the RBW setting, and the time resolution setting.
Method  Frequency Resolution Method  Frequency Resolution Setting  Time Resolution Setting  Resulting Time Resolution in Seconds 

Welch or Filter Bank  RBW (Hz)  Auto  Auto  1/RBW 
Welch or Filter Bank  RBW (Hz)  Auto  Manually entered  Time Resolution 
Welch or Filter Bank  RBW (Hz)  Manually entered  Auto  1/RBW 
Welch or Filter Bank  RBW (Hz)  Manually entered  Manually entered  Must 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 entered  Must 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 entered  Must be equal to or greater than the minimum attainable time resolution, 1/RBW. 
Tunable: Yes
To use this option, set View
to Spectrogram
or Spectrum
and spectrogram
.
See TimeResolution
.
Time span
— Time span in secondsAuto
(default)  positive scalar The time span over which the Spectrum Analyzer displays the
spectrogram specified in seconds. The time span is the product of the
desired number of spectral lines and the time resolution. The tooltip
displays the minimum allowable time span, given the current settings. If
the time span is set to Auto
, 100 spectral
lines are used.
Tunable: Yes
To use this option, set View
to Spectrogram
or Spectrum
and spectrogram
.
See TimeSpan
.
Overlap (%)
— Segment overlap percentageThis parameter defines the amount of overlap between the previous and current buffered data segments. 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
See OverlapPercent
.
Window
— Windowing methodHann
(default)  Rectangular
 BlackmanHarris
 Chebyshev
 Flat Top
 Hamming
 Kaiser
 custom window function nameThe windowing method to apply to the spectrum. Windowing is used to control the effect of sidelobes in spectral estimation. The window you specify affects the window length required to achieve a resolution bandwidth and the required number of samples per update. For more information about windowing, see Windows.
Tunable: Yes
See Window
.
Attenuation
— Sidelobe attenuation60
(default)  scalar greater than or equal to 45
The sidelobe attenuation in decibels (dB). The value must be greater
than or equal to 45
.
This parameter applies only when you set the
Window parameter to
Chebyshev
or
Kaiser
.
See SidelobeAttenuation
.
NENBW
— Normalized effective noise bandwidthThis property is readonly.
The normalized effective noise bandwidth of the window. You cannot modify this parameter; it is shown for informational purposes only. This parameter is a measure of the noise performance of the window. The value is the width of a rectangular filter that accumulates the same noise power with the same peak power gain.
The rectangular window has the smallest NENBW, with a value of 1. All other windows have a larger NENBW value. For example, the Hann window has an NENBW value of approximately 1.5.
Units
— Spectrum unitsdBm
(default)  dBW
 Watts
 Vrms
 dBV
 dBFS
The units of the spectrum. The available values depend on the value of the Type parameter.
Tunable: Yes
See SpectrumUnits
.
Full scale
— Full scale for dBFS unitsAuto
(default)  positive real scalarThe full scale used for the decibel full scale (dBFS) units. By default, the Spectrum Analyzer uses the entire spectrum scale. Specify a positive real scalar for the dBFS full scale.
Tunable: Yes
To enable this parameter, set:
Input domain to Time
Units
to dBFS
See FullScale
.
Averaging method
— Smoothing methodExponential
(default)  Running
Specify the smoothing method as:
Exponential
— Weighted average of samples. Use
the Forgetting factor
property to specify the weighted
forgetting factor.
Running
— Running average of the last
n samples. Use the Averages
property to specify n.
For more information about the averaging methods, see Averaging Method.
See AveragingMethod
.
Averages
— Number of spectral averages1
(default)  positive integerSpecify the number of spectral averages as a positive integer. The spectrum analyzer computes the current power spectrum estimate by computing a running average of the last N power spectrum estimates. This parameter defines the number of spectral averages, N.
This parameter applies only when:
View is Spectrum
or
Spectrum and spectrogram
.
Averaging method is
Running
.
See SpectralAverages
.
Forgetting factor
— Weighting forgetting factor0.9
(default)  scalar in the range (0,1]Specify the exponential weighting as a scalar value greater than 0 and less than or equal to 1.
This parameter applies only when the Averaging method is
Exponential
.
See ForgettingFactor
.
Reference load
— Reference load1
(default)  positive real scalarThe reference load in ohms that the Spectrum Analyzer uses as a reference to compute power values.
See ReferenceLoad
.
Scale
— Scale of frequency axisLinear
(default)  Logarithmic
Choose a linear or logarithm scale for the frequency axis. When the frequency span contains negative frequency values, you cannot choose the logarithmic option.
See FrequencyScale
.
Offset
— Constant frequency offset0
(default)  scalarThe constant frequency offset to apply to the entire spectrum, or a vector of frequencies to apply to each spectrum for multiple inputs. The offset parameter is added to the values on the Frequency axis in the Spectrum Analyzer window. This parameter is not used in any spectral computations. You must take the parameter into consideration when you set the Span (Hz) and CF (Hz) parameters to ensure that the frequency span is within the Nyquist frequency interval.
To use this parameter, set Input domain to Time
.
See FrequencyOffset
.
Normal trace
— Normal trace viewWhen this check box is selected, the Spectrum Analyzer calculates and plots the power spectrum or power spectrum density. Spectrum Analyzer performs a smoothing operation by averaging several spectral estimates.
To clear this check box, you must first select either the Max hold trace
or the Min hold trace
parameter. This parameter applies only when View
is Spectrum
or Spectrum and
spectrogram
.
See PlotNormalTrace
.
Max hold trace
— Maximum hold trace viewSelect this check box to enable Spectrum Analyzer to plot the maximum spectral values of all the estimates obtained.
This parameter applies only when View
is Spectrum
or Spectrum and
spectrogram
.
See PlotMaxHoldTrace
.
Min hold trace
— Minimum hold trace viewSelect this check box to enable Spectrum Analyzer to plot the minimum spectral values of all the estimates obtained.
This parameter applies only when View
is Spectrum
or Spectrum and
spectrogram
.
See PlotMinHoldTrace
.
Twosided spectrum
— Enable twosided spectrum viewSelect this check box to enable a twosided spectrum view. In this view, both negative and positive frequencies are shown. If you clear this check box, Spectrum Analyzer shows a onesided spectrum with only positive frequencies. Spectrum Analyzer requires that this parameter is selected when the input signal is complexvalued.
The Configuration Properties dialog box controls visual aspects of the Spectrum Analyzer. To open the Configuration Properties, in the Spectrum Analyzer menu, select View > Configuration Properties or select the button in the toolbar dropdown.
Title
— Display titleSpecify the display title. Enter %<SignalLabel>
to use the signal labels in the Simulink model as the axes titles.
Tunable: Yes
See Title
.
Show legend
— Display signal legendShow signal legend. The names listed in the legend are the signal names from the model. For signals with multiple channels, a channel index is appended after the signal name. Continuous signals have straight lines before their names and discrete signals have stepshaped lines.
From the legend, you can control which signals are visible. This control is equivalent to changing the visibility in the Style parameters. 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, rightclick the signal name, which hides all other signals. To show all signals, press ESC.
Note
The legend only shows the first 20 signals. Any additional signals cannot be viewed or controlled from the legend.
To enable this parameter, set View to Spectrum
or Spectrum and spectrogram
.
See ShowLegend
.
Show grid
— Show internal grid linesYlimits (minimum)
— Yaxis minimum80
(default)  scalarYlimits (maximum)
— Yaxis maximum20
(default)  scalarYlabel
— Yaxis labelTo display signal units, add (%<SignalUnits>)
to the label. At the beginning of a simulation, Simulink replaces (%SignalUnits)
with the units associated with the signals. For example, if you have a signal for velocity with units of m/s enter
Velocity (%<SignalUnits>)
See YLabel
.
Color map
— Spectrogram colormapjet(256)
(default)  hot(256)
 bone(256)
 cool(256)
 copper(256)
 gray(256)
 parula(256)
 3column matrixColorlimits (minimum)
— Spectrogram minimum80
(default)  scalarSpecify the signal power for the minimum color value of the spectrogram.
Tunable: Yes
To use this parameter, set View
to Spectrogram
or Spectrum
and spectrogram
.
See ColorLimits
.
Colorlimits (maximum)
— Spectrogram maximumSpecify the signal power for the maximum color value of the spectrogram.
Tunable: Yes
To use this parameter, set View
to Spectrogram
or Spectrum
and spectrogram
.
See ColorLimits
.
The Style dialog box controls how to Spectrum Analyzer appears. To open the Style properties, in the Spectrum Analyzer menu, select View > Style or select the button in the toolbar dropdown.
Figure color
— Window backgroundSpecify the color that you want to apply to the background of the scope figure.
Plot type
— Plot typeLine
(default)  Stem
Axes colors
— Axes background colorSpecify the color that you want to apply to the background of the axes.
Properties for line
— Channel for visual property settingsSpecify the channel for which you want to modify the visibility, line properties, and marker properties.
Visible
— Channel visibilitySpecify whether the selected channel is visible. If you clear this check box, the line disappears. You can also change signal visibility using the scope legend.
Line
— Line styleSpecify the line style, line width, and line color for the selected channel.
Marker
— Data point markersnone
(default)Specify marks for the selected channel to show at its data points. This parameter is similar to the Marker property for plots. You can choose any of the marker symbols from the dropdown.
The Axes Scaling dialog box controls the axes limits of the Spectrum Analyzer. To open the Axes Scaling properties, in the Spectrum Analyzer menu, select Tools > Axes Scaling > Axes Scaling Properties.
Axes scaling/Color scaling
— Automatic axes scalingAuto
(default)  Manual
 After N Updates
Specify when the scope automatically scales the yaxis. If the
spectrogram is displayed, specify when the scope automatically scales
the color axis. By default, this parameter is set to
Auto
, and the scope does not shrink the
yaxis limits when scaling the axes or color. You can select one of the
following options:
Auto
— The scope scales
the axes or color as needed, both during and after
simulation. Selecting this option shows the Do not
allow Yaxis limits to shrink or Do
not allow color limits to shrink.
Manual
— When you select
this option, the scope does not automatically scale the axes
or color. You can manually scale the axes or color in any of
the following ways:
Select Tools > Scaling Properties.
Press one of the Scale Axis Limits toolbar buttons.
When the scope figure is the active window, press Ctrl+A.
After N Updates
—
Selecting this option causes the scope to scale the axes or
color after a specified number of updates. This option is
useful, and most efficient, when your frequency signal
values quickly reach steadystate after a short period.
Selecting this option shows the Number of
updates edit box where you can modify the
number of updates to wait before scaling.
Tunable: Yes
See AxesScaling
.
Do not allow Yaxis/color limits to shrink
— Axes scaling limitsWhen you select this parameter, the yaxis is allowed to grow during axes scaling operations. If the spectrogram is displayed, selecting this parameter allows the color limits to grow during axis scaling. If you clear this check box, the yaxis or color limits can shrink during axes scaling operations.
This parameter appears only when you select
Auto
for the Axis
scaling or Color scaling
parameter. When you set the Axes scaling or
Color scaling parameter to
Manual
or After N
Updates
, the yaxis or color
limits can shrink.
Number of updates
— Number of updates before scaling10
(default)  positive numberThe number of updates after which the axes scale, specified as a positive integer. If the spectrogram is displayed, this parameter specifies the number of updates after which the color axes scales.
Tunable: Yes
This parameter appears only when you set Axes scaling/Color scaling to After N Updates
.
Scale limits at stop
— Scale axes at stopSelect this check box to scale the axes when the simulation stops. If the spectrogram is displayed, select this check box to scale the color when the simulation stops. The yaxis is always scaled. The xaxis limits are only scaled if you also select the Scale Xaxis limits check box.
Data range (%)
— Percent of axesSet the percentage of the axis that the scope uses to display the data when scaling the axes. If the spectrogram is displayed, set the percentage of the power values range within the colormap. Valid values are from 1 through 100. For example, if you set this parameter to 100
, the scope scales the axis limits such that your data uses the entire axis range. If you then set this parameter to 30
, the scope increases the yaxis or color range such that your data uses only 30% of the axis range.
Tunable: Yes
Align
— Alignment along axesCenter
(default)  Bottom
 Top
 Left
 Right
Specify where the scope aligns your data along the axis when it scales the axes. If the spectrogram is displayed, specify where the scope aligns your data along the axis when it scales the color. If you are using CCDF Measurements, the x axis is also configurable.
Tunable: Yes
Data Types 

Direct Feedthrough 

Multidimensional Signals 

VariableSize Signals 

ZeroCrossing Detection 

When you choose the Welch
method, the power spectrum
estimate is averaged modified periodograms.
Given the signal input, x
, the Spectrum Analyzer does the
following:
Multiplies x
by the given window and scales the result
by the window power. The Spectrum Analyzer uses the
RBW
or the Window
Length
setting in the Spectrum
Settings pane to determine the data window length.
Computes the FFT of the signal, Y
, and takes the square
magnitude using Z = Y.*conj(Y)
.
Computes the current power spectrum estimate by taking the moving average of the last N number of Z's, and scales the answer by the sample rate. For details on the moving average methods, see Averaging Method.
Spectrum Analyzer requires that a minimum number of samples to compute a spectral estimate. 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 resolution bandwidth, RBW, by the following equation, or to the window length, by the equation shown in step 2.
$${N}_{samples}=\frac{\left(1\frac{{O}_{p}}{100}\right)\times NENBW\times {F}_{s}}{RBW}$$
The normalized effective noise bandwidth, NENBW, is a factor that depends on the windowing method. Spectrum Analyzer shows the value of NENBW in the Window Options pane of the Spectrum Settings pane. Overlap percentage, O_{p}, is the value of the Overlap % parameter in the Window Options pane of the Spectrum Settings pane. F_{s} is the sample rate of the input signal. Spectrum Analyzer shows sample rate in the Main Options pane of the Spectrum Settings pane.
When in RBW (Hz) mode, the window length required to compute one spectral update, N_{window}, is directly related to the resolution bandwidth and normalized effective noise bandwidth:
$${N}_{window}=\frac{NENBW\times {F}_{s}}{RBW}$$
When in Window Length mode, the window length is used as specified.
The number of input samples required to compute one spectral update, N_{samples}, is directly related to the window length and the amount of overlap by the following equation.
$${N}_{samples}=\left(1\frac{{O}_{p}}{100}\right){N}_{window}$$
When you increase the overlap percentage, fewer new input samples are needed to compute a new spectral update. For example, if the window length is 100, then the number of input samples required to compute one spectral update is given as shown in the following table.
O_{p}  N_{samples} 

0%  100 
50%  50 
80%  20 
The normalized effective noise bandwidth, NENBW, is a window parameter determined by the window length, N_{window}, and the type of window used. If w(n) denotes the vector of N_{window} window coefficients, then NENBW is given by the following equation.
$$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}}$$
When in RBW (Hz) mode, you can set the resolution bandwidth using the value of the RBW (Hz) parameter on the Main options pane of the Spectrum Settings pane. You must specify a value to ensure 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$$
By default, the RBW (Hz) parameter on the Main
options pane is 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. When you set
RBW (Hz) to Auto
,
RBW is calculated as:
$$RB{W}_{auto}=\frac{span}{1024}$$
When in Window Length mode, you specify N_{window} and the resulting RBW is:
$$\frac{NENBW\times {F}_{s}}{{N}_{window}}$$
Sometimes, the number of input samples provided are not sufficient to achieve the resolution bandwidth that you specify. When this situation occurs, Spectrum Analyzer displays a message:
Spectrum Analyzer removes this message and displays a spectral estimate when enough data has been input.
Note
The number of FFT points (N_{fft}) is independent of the window length (N_{window}). You can set them to different values if N_{fft} is greater than or equal to N_{window}.
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_{M1}(m), of sample rate fs/M.
The variable M represents the number of frequency bands in the
filter bank. When the frequency resolution method is set to
NumFrequencyBands
, M is equal to the
value you specify for the number of frequency bands. When the frequency resolution
method is set to RBW
, M is equal to the
number of data points that are needed to achieve the specified RBW value or 1024,
whichever is larger. The number of taps per frequency band specifies the number of
filter coefficients for each frequency band of the filter bank. The total number of
filter coefficients is equal to number of taps per band times the number of frequency
bands, M. For more information on the analysis filter bank and how it
is implemented, see the More About and the Algorithm sections in
dsp.Channelizer
.
After the broadband input signal is split into multiple narrow bands, the Spectrum Analyzer computes the power in each narrow band using the following equation. Each Z_{i} value becomes the estimate of the power over that narrow frequency band.
$${Z}_{i}=\frac{1}{L}{\displaystyle \sum _{m=0}^{L1}{\left{y}_{i}[m]\right}^{2}}$$
L is length of the narrow band signal, y_{i}(m), and i = 1, 2, …, M−1.
The power values in all the narrow bands (denoted by the Z_{i}) form the Z vector.
$$Z=[{Z}_{0},\text{\hspace{0.17em}}{Z}_{1},\text{\hspace{0.17em}}{Z}_{2},\cdots ,{Z}_{M1}]$$
The current Z vector is averaged with the previous Z vectors using one of the two moving average methods: Running 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 RBW (Hz) or the Number of frequency band property in the Spectrum Settings pane to determine the input frame length.
Spectrum Analyzer requires a minimum number of samples to compute a spectral estimate. 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 resolution bandwidth, RBW, by the following equation.
$${N}_{samples}=\frac{{F}_{s}}{RBW}$$
F_{s} is the sample rate of the input signal. Spectrum Analyzer shows sample rate in the Main Options pane of the Spectrum Settings pane.
When in RBW (Hz) mode, you can set the resolution bandwidth using the value of the RBW (Hz) parameter on the Main options pane of the Spectrum Settings pane. You must specify a value to ensure 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$$
By default, the RBW parameter on the Main
options pane is 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. Thus, when you
set RBW to Auto
, it is
calculated by the following equation.$$RB{W}_{auto}=\frac{span}{1024}$$
When in Number of frequency bands mode, you specify the
input frame size. When the number of frequency bands is
Auto
, the resulting RBW is:
$$RBW=\frac{{F}_{s}}{\text{InputFrameSize}}$$
When the number of frequency bands is manually specified, the resulting RBW is:
$$RBW=\frac{{F}_{s}}{FFTLength}$$
Sometimes, the number of input samples provided are not sufficient to achieve the resolution bandwidth that you specify. When this situation occurs, Spectrum Analyzer displays a message:
Spectrum Analyzer removes this message and displays a spectral estimate when enough data has been input.
When the PlotAsTwoSidedSpectrum property is
set to true
, the interval is $$\left[\frac{SampleRate}{2},\frac{SampleRate}{2}\right]+FrequencyOffset$$ hertz.
When the PlotAsTwoSidedSpectrum
property is set to false
, the
interval is $$\left[0,\frac{SampleRate}{2}\right]+FrequencyOffset$$ hertz.
Spectrum Analyzer calculates and plots the power spectrum, power spectrum density, and RMS computed by the modified
Periodogram estimator. For more information about the Periodogram method, see periodogram
.
Power Spectral Density — The power spectral density (PSD) is given by the following 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(n1)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. On every input signal frame, Spectrum Analyzer generates as many overlapping windows as possible, with each window denoted as x^{(p)}[n], and computes their periodograms. 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 the following 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(n1)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.
When set to Auto
, the frequency vector for frequencydomain input is calculated by the
software.
When the PlotAsTwoSidedSpectrum property is set to true, the frequency vector is:
$$\left[\frac{SampleRate}{2},\frac{SampleRate}{2}\right]$$
When the PlotAsTwoSidedSpectrum property is set to false, the frequency vector is:
$$\left[0,\frac{SampleRate}{2}\right]$$
The Occupied BW is calculated as follows.
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, the power distributed in each frequency is summed until this result is
$$\frac{100OccupiedBW\%}{2}$$
of the total power.
Determine the upper frequency value. Starting at the highest frequency in the range and moving downward, the power distributed in each frequency is summed until the result reaches
$$\frac{100OccupiedBW\%}{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.
The Distortion Measurements are computed as follows.
Spectral content is estimated 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, all spectral content centered at DC (0 Hz) is removed from the spectrum and the amount of bandwidth cleared (W_{0}) is recorded.
The fundamental power (P_{1}) is determined from the remaining maximum value of the displayed spectrum. A local estimate (Fe_{1}) of the fundamental frequency is made by computing the central moment of the power near the peak. The bandwidth of the fundamental power content (W_{1}) is recorded. Then, the power from the fundamental is removed as in step 1.
The power and width of the higherorder harmonics (P_{2}, W_{2}, P_{3}, W_{3}, etc.) are determined in succession by examining the frequencies closest to the appropriate multiple of the local estimate (Fe_{1}). Any spectral content that decreases monotonically about the harmonic frequency is removed from the spectrum first before proceeding to the next harmonic.
Once the DC, fundamental, and harmonic content is removed from the spectrum, the power of the remaining spectrum is examined for its sum (P_{remaining}), peak value (P_{maxspur}), and median value (P_{estnoise}).
The sum of all the removed bandwidth is computed as W_{sum} = W_{0} + W_{1} + W_{2} +...+ W_{n}.
The sum of powers of the second and higherorder harmonics are computed as P_{harmonic} = P_{2} + P_{3} + P_{4} +...+ P_{n}.
The sum of the noise power is estimated 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.
The metrics for SNR, THD, SINAD, and SFDR are then computed 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}$$
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 may 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.
The DC component is ignored.
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, 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, the thirdorder intercept (TOI) point is computed as follows, where P is power in decibels of the measured power referenced to 1 milliwatt (dBm):
TOI_{lower} = P_{F1} + (P_{F2}  P_{(2F1F2)})/2
TOI_{upper} = P_{F2} + (P_{F1}  P_{(2F2F1)})/2
TOI = + (TOI_{lower} + TOI_{upper})/2
The moving average is calculated using one of the two methods:
Running
— For each frame of input, average the last
Nscaled Z vectors, which are computed
by the algorithm. The variable N is the value you specify for
the number of spectral averages. If the algorithm does not have enough
Z vectors, the algorithm uses zeros to fill the empty
elements.
Exponential
— The moving average algorithm using the exponential weighting method updates the weights and computes the moving average recursively for each Z vector that comes in by using the following recursive equations:
$$\begin{array}{l}{w}_{N}=\lambda {w}_{N1}+1\\ {\overline{z}}_{N}=\left(1\frac{1}{{w}_{N}}\right){\overline{z}}_{N1}+\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}}_{N1}$$ — Moving average until the previous Z vector
$$\left(1\frac{1}{{w}_{N}}\right){\overline{z}}_{N1}$$ — Effect of the previous Z vectors on the average
$${\overline{z}}_{N}$$ — Moving average including the current Z vector
This block can be used for simulation visibility in systems that generate code, but is not included in the generated code.
This block can be used for simulation visibility in subsystems that generate HDL code, but is not included in the hardware implementation.
This block can be used for simulation visibility in systems that generate PLC code, but is not included in the generated code.
This block accepts fixedpoint input, but converts it to double
for display.
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
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: .
Select web siteYou can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.