0% found this document useful (0 votes)
254 views

Display Frequency Spectrum of Time-Domain Signals - MATLAB PDF

Uploaded by

Risqi Raharjo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
254 views

Display Frequency Spectrum of Time-Domain Signals - MATLAB PDF

Uploaded by

Risqi Raharjo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

1/9/2019 Display frequency spectrum of time-domain signals - MATLAB

Spectrum Analyzer
Display frequency spectrum of time-domain signals

Library
Utilities

Description

 Note
The Spectrum Analyzer block in the Simscape™ product contains a subset of functionality of the DSP System
Toolbox™ block with the same name. This page describes the block configuration and functionality available
with a Simscape license. If you also have a DSP System Toolbox license, then the Spectrum Analyzer block in
the Simscape > Utilities library is identical to the block in the DSP System Toolbox > Sinks library. For more
information, see Spectrum Analyzer in the DSP System Toolbox documentation.

The Spectrum Analyzer block accepts input signals with discrete sample times and displays frequency spectra of these
signals.

To use a Spectrum Analyzer block, instead of a regular scope, in a Simscape model:

1. Add a Spectrum Analyzer block to your block diagram.


2. If your model uses a variable-step solver, also add a Rate Transition block and connect it to the input of the
Spectrum Analyzer, setting the Output port sample time to the sample time you wish the Spectrum Analyzer to
use.
If your model uses a local solver, then it produces output physical signals with discrete sample times and you do
not need to add a Rate Transition block. However, if you need to down-sample from the solver fixed step size, you
can also use a Rate Transition block. For more information on using local solvers, see Making Optimal Solver
Choices for Physical Simulation.
3. Use a PS-Simulink Converter block to connect the output physical signal of interest to the input of the Spectrum
Analyzer block (or to the input of the Rate Transition block, if using one). For more information, see Connecting
Simscape Diagrams to Simulink Sources and Scopes. You can also use additional signal processing blocks
between the PS-Simulink Converter and the Spectrum Analyzer to enhance signal quality.
4. Run the simulation. The Spectrum Analyzer, referred to here as the scope, opens and displays the frequency
spectrum of the signal.

https://www.mathworks.com/help/physmod/simscape/ref/spectrumanalyzer.html 1/17
1/9/2019 Display frequency spectrum of time-domain signals - MATLAB

 Note
To prevent the scope from opening when you run your model, right-click the scope icon and select Comment
Out. If the scope is already open, and you comment it out in the model, the scope displays, “No data can be
shown because this scope is commented out.” Select Uncomment to turn the scope back on.

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 Reduce Plot Rate to
Improve Performance option. In the Spectrum Analyzer menu, select Simulation > Reduce Plot Rate to Improve
Performance to clear the check box. Tunable (Simulink).

 Note

https://www.mathworks.com/help/physmod/simscape/ref/spectrumanalyzer.html 2/17
1/9/2019 Display frequency spectrum of time-domain signals - MATLAB

When this check box is selected, 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.

Spectrum Settings
The Spectrum Settings panel appears at the right side of the Spectrum Analyzer figure. This panel enables you to
modify settings to control the manner in which the spectrum is calculated. You can choose to hide or display the
Spectrum Settings panel. In the Spectrum Analyzer menu, select View > Spectrum Settings. Alternatively, in the
Spectrum Analyzer toolbar, select the Spectrum Settings button.

The Spectrum Settings panel is separated into three panes, labeled Main Options, Window Options, and Trace
Options. You can expand each pane to see the available options.

Main Options Pane


The Main Options pane contains:

• Type — The type of spectrum to display.


˗ Power — show the power spectrum.
˗ Power density — show the power spectral density. The power spectral density is the magnitude of the
spectrum normalized to a bandwidth of 1 hertz.
˗ RMS — show the root mean square of the frequency.

• Sample rate (Hz) — The sample rate, in hertz, of the input signals. Select Inherited to use the same sample rate
as the input signal. To specify a sample rate, enter its value.
• RBW (Hz) — The resolution bandwidth, in hertz. This property defines the smallest positive frequency that can be
resolved. By default, this property 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 property to a numeric value, then you must specify a value that ensures there are at least two RBW
intervals over the specified frequency span. In other words, the ratio of the overall frequency span to RBW must be
span
at least two: > 2 .
RBW

• Samples/update — The number of input samples required to compute one spectral update. You cannot modify this
property; it is shown here for display purposes only. This property is directly related to RBW by the following
( )
Op
1 − × NENBW × Fs
100
equation: Nsamples = or to the window length by this equation:
RBW

. NENBW is the normalized effective noise bandwidth, a factor of the


windowing method used, which is shown in the Window Options pane. 0 is the overlap percentage. F is the
p s

sample rate. If the number of samples provided in the input are not sufficient to achieve the resolution bandwidth
that you specify, Spectrum Analyzer produces a message on the display as shown in the following figure.

Windows Options Pane

https://www.mathworks.com/help/physmod/simscape/ref/spectrumanalyzer.html 3/17
1/9/2019 Display frequency spectrum of time-domain signals - MATLAB

The Window Options pane contains:

• Overlap (%) — The segment overlap percentage. This 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.
• Window — The windowing method to apply to the spectrum. Available options are Rectangular and Hann.
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 (Signal Processing Toolbox) in the Spectral Analysis section.
• NENBW — Normalized Effective Noise Bandwidth of the window. You cannot modify this parameter; it is a readout
shown here for display purposes only. This parameter is a measure of the noise performance of the window. It is the
width of a rectangular filter that accumulates the same noise power with the same peak power gain. NENBW can be

calculated from the windowing function using the following equation: . 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.

Trace Options Pane


The Trace Options pane contains:

• Units — The units of the spectrum. Depends on the value of the spectrum type.

Spectrum Type Units

Power dBV

Power density dBm/Hz

RMS Vrms or dBV

• Averages — Specify as a positive, scalar integer the number of spectral averages. Spectrum Analyzer computes
the current power spectrum estimate by computing a running average of the last N power spectrum estimates. This
property defines the number of spectral averages, N.
• Reference load — The reference load, in ohms, used to scale the spectrum. Specify as a real, positive scalar the
load, in ohms, that the Spectrum Analyzer uses as a reference to compute power values.
• Scale — Linear or logarithmic scale. When the frequency span contains negative frequency values, Spectrum
Analyzer disables the logarithmic option.
• Offset — The 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. It is not used in any spectral computations.
• Two-sided spectrum — Select this check box to enable two-sided spectrum view. In this view, both negative and
positive frequencies are shown. If you clear this check box, Spectrum Analyzer shows a one-sided spectrum with
only positive frequencies. Spectrum Analyzer requires that this parameter is selected when the input signal is
complex-valued.

Measurements Panels

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.

https://www.mathworks.com/help/physmod/simscape/ref/spectrumanalyzer.html 4/17
1/9/2019 Display frequency spectrum of time-domain signals - MATLAB

In the Scope menu, select Tools > Measurements > Cursor Measurements. Alternatively, in the Scope toolbar, click
the Cursor Measurements button.

The Cursor Measurements panel for the spectrum:

You can use the mouse or the left and right arrow keys to move vertical or waveform cursors and the up and down
arrow keys for horizontal cursors.

In the Settings pane, you can modify the type of screen cursors used for calculating measurements. When more than
one signal is displayed, you can assign cursors to each trace individually.

• Screen Cursors — Shows screen cursors (for spectrum and dual view only).
• Horizontal — Shows horizontal screen cursors (for spectrum and dual view only).
• Vertical — Shows vertical screen cursors (for spectrum and dual view only).
• Waveform Cursors — Shows cursors that attach to the input signals (for spectrum and dual view only).
• 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) and power (dBm) value measurements. Channel Power shows
the total power between the cursors.

• 1 — Shows or enables you to modify the frequency at cursor number one.


• 2 — Shows or enables you to modify the frequency at cursor number two.
• Δ — Shows the absolute value of the difference in the frequency 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.

https://www.mathworks.com/help/physmod/simscape/ref/spectrumanalyzer.html 5/17
1/9/2019 Display frequency spectrum of time-domain signals - MATLAB

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.

https://www.mathworks.com/help/physmod/simscape/ref/spectrumanalyzer.html 6/17
1/9/2019 Display frequency spectrum of time-domain signals - MATLAB

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.

Distortion Measurements Panel


The Distortion Measurements panel displays harmonic distortion and intermodulation distortion measurements.

• From the menu, select Tools > Measurements > Distortion Measurements.
• On the toolbar, click the Distortion Measurements button.

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.
See Distortion Measurements (DSP System Toolbox) for information on how distortion measurements are
calculated.

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

https://www.mathworks.com/help/physmod/simscape/ref/spectrumanalyzer.html 7/17
1/9/2019 Display frequency spectrum of time-domain signals - MATLAB

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.
• Label Harmonics — Select Label Harmonics to add numerical labels to each harmonic in the spectrum display.
• 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.
https://www.mathworks.com/help/physmod/simscape/ref/spectrumanalyzer.html 8/17
1/9/2019 Display frequency spectrum of time-domain signals - MATLAB

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

( )
S
SINAD = 10 ⋅ log10
N + 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).

• Label frequencies — Select Label frequencies to add numerical labels to the first-order intermodulation product
and third-order frequencies in the spectrum analyzer display.
• F1 — Lower fundamental first-order frequency
• F2 — Upper fundamental first-order frequency
• 2F1 - F2 — Lower intermodulation product from third-order harmonics
• 2F2 - F1 — Upper intermodulation product from third-order harmonics
• 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.

Trace Selection Panel


When you use the scope to view multiple signals, the Trace Selection panel appears if you have more than one signal
displayed and you click any of the other Measurements panels. The Measurements panels display information about
only the signal chosen in this panel. Choose the signal name for which you would like to display time domain
measurements.

You can choose to hide or display the Trace Selection panel. In the Scope menu, select Tools > Measurements >
Trace Selection.

https://www.mathworks.com/help/physmod/simscape/ref/spectrumanalyzer.html 9/17
1/9/2019 Display frequency spectrum of time-domain signals - MATLAB

Visuals — Spectrum Properties


The Visuals—Spectrum Properties dialog box controls the visual configuration settings of the Spectrum Analyzer
display. From the Spectrum Analyzer menu, select View > Configuration Properties to open this dialog box.
Alternatively, in the Spectrum Analyzer toolbar, click the Configuration Properties button.

Title
Specify the display title as a character vector. Enter %<SignalLabel> to use the signal labels in the Simulink Model
as the axes titles. This property is Tunable (Simulink).

By default, the display has no title.

Show legend
Select this check box to show the legend in the display. The channel legend displays a name for each channel of
each input signal. When the legend appears, you can place it anywhere inside of the scope window. To turn off the
legend, clear the Show legend check box. Tunable (Simulink)

You can edit the name of any channel in the legend by double-clicking the current name and entering a new channel
name. By default, if the signal has multiple channels, the scope uses an index number to identify each channel of
that signal. To change the appearance of any channel of any input signal in the scope window, from the scope menu,
select View > Style. The legend lets you modify what signals are shown. To show only one signal, click the signal
name. To toggle a signal on/off, right-click the signal name.

The legend lets you modify what signals are shown. To show only one signal, click the signal name. To toggle a
signal on/off, right-click the signal name.

Show grid
When you select this check box, a grid appears in the display of the scope figure. To hide the grid, clear this check
box. Tunable (Simulink)

Y-limits (Minimum)
Specify the minimum value of the y-axis. Tunable (Simulink)

Y-limits (Maximum)
Specify the maximum value of the y-axis. Tunable (Simulink)

Y-axis label
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 after this text as one of 'dBm', 'dBW', 'Watts', 'dBm/Hz', 'dBW/Hz', or 'Watts/Hz'.
Tunable (Simulink).

Style Dialog Box


In the Style dialog box, you can customize the style of spectrum display. You are able to change the color of the figure,
the background and foreground colors of the axes, and properties of the lines. From the Spectrum Analyzer menu,
select View > Style to open this dialog box.

https://www.mathworks.com/help/physmod/simscape/ref/spectrumanalyzer.html 10/17
1/9/2019 Display frequency spectrum of time-domain signals - MATLAB

Properties
The Style dialog box allows you to modify the following properties of the Spectrum Analyzer figure:

Figure color
Specify the color that you want to apply to the background of the scope figure. By default, the figure color is gray.

Plot type
Specify whether to display a Line or Stem plot.

Axes colors
Specify the color that you want to apply to the background of the axes.

Properties for line


Specify the channel for which you want to modify the visibility, line properties, and marker properties.

Visible
Specify whether the selected channel should be visible. If you clear this check box, the line disappears.

Line
Specify the line style, line width, and line color for the selected channel.

Marker
Specify marks for the selected channel to show at its data points. This parameter is similar to the Marker property for
plot objects. You can choose any of the marker symbols from the dropdown.

Algorithms
Spectrum Analyzer uses the RBW or the Window Length setting in the Spectrum Settings panel to determine the data
window length. The value of the FrequencyResolutionMethod property determines whether RBW or window length is
used. Then, it partitions the input signal into a number of windowed data segments. Finally, Spectrum Analyzer uses the
modified periodogram method to compute spectral updates, averaging the windowed periodograms for each segment.

1. Spectrum Analyzer requires that a minimum number of samples have been provided before it computes 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 1b.
( )
Op
1 − × NENBW × Fs
100
Nsamples =
RBW

https://www.mathworks.com/help/physmod/simscape/ref/spectrumanalyzer.html 11/17
1/9/2019 Display frequency spectrum of time-domain signals - MATLAB

The normalized effective noise bandwidth, NENBW, is a factor that depends on the windowing method. Spectrum
Analyzer shows NENBW in the Window Options pane of the Spectrum Settings panel. Overlap percentage, O , p

is the value of the Overlap % parameter in the Window Options pane of the Spectrum Settings panel. F is the s

sample rate of the input signal. Spectrum Analyzer shows sample rate in the Main Options pane of the Spectrum
Settings panel.
a. When in RBW mode, the window length required to compute one spectral update, N , is directly related to
window

the resolution bandwidth and normalized effective noise bandwidth by the following equation.

When in WindowLength mode, the window length is used as specified.


b. The number of input samples required to compute one spectral update, N , is directly related to the
samples

window length and the amount of overlap by the following equation.

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.

Op Nsamples

0% 100

50% 50

80% 20

c. The normalized effective noise bandwidth, NENBW, is a window parameter determined by the window length,
Nwindow, and the type of window used. If w(n) denotes the vector of N window coefficients, then NENBW is
window

given by the following equation.

d. When in RBW mode, you can set the resolution bandwidth using the value of the RBW parameter on the Main
options pane of the Spectrum Settings panel. 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, as given in the following equation.
span
> 2
RBW

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
span. Thus, when you set RBW to Auto, it is calculated by the following equation. RBW auto
=
1024

e. When in window length mode, you specify N window and the resulting RBW is

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 produces a message on the display, as shown in
the following figure.

https://www.mathworks.com/help/physmod/simscape/ref/spectrumanalyzer.html 12/17
1/9/2019 Display frequency spectrum of time-domain signals - MATLAB

Spectrum Analyzer removes this message and displays a spectral estimate as soon as enough data has been
input. Notice that this behavior differs from the Spectrum Scope block in versions R2012b and earlier. If the Buffer
input check box was selected, the Spectrum Scope block computed a spectral update using the number of
samples given by the Buffer size parameter. Otherwise, the Spectrum Scope block computed a spectral update
using the number of samples in each frame.
2. 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 in the
Signal Processing Toolbox™ documentation.
Power Spectral Density — The power spectral density (PSD) is given by the following equation.

In this equation, x[n] is the discrete input signal. On every input signal frame, Spectrum Analyzer generates as
many overlapping windows as possible, each window denoted as x [n], and computes their periodograms.
(p)

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.

 Note
The number of FFT points (N ) is independent of the window length (N
fft window). You can set them to different
values provided that N is greater than or equal to N
fft .
window

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 sum is 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 it reaches 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.

1. Spectral content is estimated by finding peaks in the spectrum. When the algorithm detects a peak, it ignores all
adjacent content that decreases monotonically from the peak. After recording the width of the peak, it clears all
monotonically decreasing values (that is, it treats all of these values as if they belong to the peak). Using this

https://www.mathworks.com/help/physmod/simscape/ref/spectrumanalyzer.html 13/17
1/9/2019 Display frequency spectrum of time-domain signals - MATLAB

method, all spectral content centered at DC (0 Hz) is removed from the spectrum and the amount of bandwidth
cleared (W ) is recorded.
0

2. The fundamental power (P ) is determined from the remaining maximum value of the displayed spectrum. A local
1

estimate (Fe ) of the fundamental frequency is made by computing the central moment of the power in the vicinity
1

of the peak. The bandwidth of the fundamental power content (W ) is recorded. Then, the power associated from
1

the fundamental is removed as in step 1.


3. The power and width of the second, and higher order harmonics (P , W , P , W , etc.) are determined in succession
2 2 3 3

by examining the frequencies closest to the appropriate multiple of the local estimate (Fe ). Any spectral content 1

that decreases in a monotonically about the harmonic frequency is removed from the spectrum first before
proceeding to the next harmonic.
4. Once the DC, fundamental, and harmonic content is removed from the spectrum, the power of the remaining
spectrum is examined for its sum (P ) peak value (P
remaining ), and its median value (P
maxspur ). estnoise

5. The sum of all the removed bandwidth is computed as W sum = W +W +W +...+W .


0 1 2 n

The sum of powers of the second and higher order harmonics are computed as P harmonic = P +P +P +...+P .
2 3 4 n

6. The sum of the noise power is then estimated as P = (P *dF + P


noise *W )/RBW, where dF is the
remaining estnoise sum

absolute difference between frequency bins, and RBW is the resolution bandwidth of the window.
7. The metrics for SNR, THD, SINAD, and SFDR are then computed from the estimates.
( )
Pharmonic
THD = 10 ⋅ log10
P1
( )
P1
SINAD = 10 ⋅ log10
Pharmonic + Pnoise
( )
P1
SNR = 10 ⋅ log10
Pnoise
( )
P1
SFDR = 10 ⋅ log10
( (
max Pmaxspur , max P2, P3, ..., Pn ))

The following considerations apply to Distortion Measurements.

• The harmonic distortion measurements use the spectrum trace shown in the display as the input to the
measurements. The default Hann window setting of the Spectrum Analyzer may exhibit leakage that can completely
mask the noise floor of the measured signal.

https://www.mathworks.com/help/physmod/simscape/ref/spectrumanalyzer.html 14/17
1/9/2019 Display frequency spectrum of time-domain signals - MATLAB

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. Consider
using a Kaiser window with a high attenuation (up to 330dB) to minimize spectral leakage if your application can
tolerate the increased equivalent noise bandwidth (ENBW) of the Kaiser window.

https://www.mathworks.com/help/physmod/simscape/ref/spectrumanalyzer.html 15/17
1/9/2019 Display frequency spectrum of time-domain signals - MATLAB

• 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 third-order intercept (TOI) point is computed as follows, where P is power in
decibels of the measured power referenced to one milliwatt (dBm).:
˗ TOIlower =P
F1 + (PF2 -P(2F1-F2) )/2
˗ TOIupper =P F2 + (P F1 -P (2F2-F1) )/2
˗ TOI = + (TOI lower + TOI upper )/2

Limitations
Spectrogram mode and the Window Length setting in the Spectrum Settings panel require a DSP System Toolbox
license. They are not available if you are using a Spectrum Analyzer block from the Simscape > Utilities library without
a DSP System Toolbox license.

See Also
Spectrum Analyzer | dsp.SpectrumAnalyzer

Topics
Water Hammer Effect
https://www.mathworks.com/help/physmod/simscape/ref/spectrumanalyzer.html 16/17
1/9/2019 Display frequency spectrum of time-domain signals - MATLAB

Introduced in R2016b

How useful was this information?

Why did you choose this rating?

https://www.mathworks.com/help/physmod/simscape/ref/spectrumanalyzer.html 17/17

You might also like