Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Spectrograms are a two-dimensional representation of the power spectrum of a signal as this signal sweeps through time. They give a visual understanding of the frequency content of your signal. Each line of the spectrogram is one periodogram computed using the Welch's algorithm of averaging modified periodogram.

To show the concepts of the spectrogram, this example uses the
model `ex_psd_sa`

as the starting point. Open the
model and double-click the Spectrum Analyzer block.
In the **Spectrum Settings** pane, change **Type** to `Spectrogram`

.
Run the model. You can see the spectrogram output in the Spectrum
Analyzer window.

Power spectrum density is computed as a function of frequency `f`

and
is plotted as a horizontal line. Each point on this line is given
a specific color based on the value of the power density at that particular
frequency. The color is chosen based on the colormap seen at the top
of the display. To change the colormap, click **View** > ** Configuration Properties**,
and choose one of the options in **color map**.
Make sure **Type** is set to `Spectrogram`

.
By default, **color map** is set to `jet(256)`

.

The two frequencies of the sine wave are distinctly visible at 5 kHz and 10 kHz. The sine wave is embedded in Gaussian noise, which has a variance of 0.0001. This value corresponds to a power of -40 dBm. The color that maps to -40 dBm is assigned to the noise spectrum. The power of the sine wave is 26.9 dBm at 5 kHz and 10 kHz. The color used in the display at these two frequencies corresponds to 26.9 dBm on the colormap. For more information on how the power is computed in dBm, see 'Conversion of power in watts to dBW and dBm'.

To confirm the dBm values, change **Type** to `Power`

.
This view shows the power of the signal at various frequencies.

You can see that the two peaks in the power display have an amplitude of 26.9 dBm and the white noise is averaging around -40 dBm.

In the spectrogram display, time scrolls from bottom to top,
so the most recent data is shown at the bottom of the display. As
the simulation time increases, the offset time also increases to keep
the vertical axis limits constant while accounting for the incoming
data. The `Offset`

value, along with the simulation
time, is displayed at the bottom-right corner of the spectrogram scope.

Resolution Bandwidth (RBW) is the minimum frequency bandwidth
that can be resolved by the spectrum analyzer. By default, **RBW
(Hz)** is set to `Auto`

. In this
mode, *RBW* is the ratio of the frequency span
to 1024. In a two-sided spectrum, this value is F_{s}/1024,
while in a one-sided spectrum, it is (F_{s}/2)/1024.

Using this value of *RBW*, the window length
(N_{samples}) is computed iteratively using this
relationship:

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

*Overlap* is the amount of overlap between
the previous and current buffered data segments. *NENBW* is
the equivalent noise bandwidth of the window. For more information
on the details of the spectral estimation algorithm, see Spectral Analysis.

To distinguish between two frequencies in the display, the distance
between the two frequencies must be at least RBW. In this example,
the distance between the two peaks is 5000 Hz, which is greater than *RBW*.
Hence, you can see the peaks distinctly.

Time resolution is the distance between two spectral lines in
the vertical axis. By default, **Time res (s)** is
set to `Auto`

. In this mode, the value of
time resolution is `1/RBW`

s, which is the minimum
attainable resolution. You can also specify the **Time res
(s)** as a numeric value.

The spectrum analyzer provides three units to specify the power: `Watts`

, `dBm`

,
and `dBW`

. By default, **Units** is
set to `dBm`

.

Power in dBW is:

$${P}_{dBW}=10\mathrm{log}10(power\text{\hspace{0.17em}}in\text{\hspace{0.17em}}watt/1\text{\hspace{0.17em}}watt)$$

Power in dBm is:

$${P}_{dBm}=10\mathrm{log}10(power\text{\hspace{0.17em}}in\text{\hspace{0.17em}}watt/1\text{\hspace{0.17em}}milliwatt)$$

For a sine wave signal with an amplitude (A) of 1 V, the power of a one-sided spectrum in Watts is:

$${A}^{2}/2$$

In this example, this power equals 0.5 W. Corresponding power in dBm is:

$$\begin{array}{l}{P}_{dBm}=10\mathrm{log}10(power\text{\hspace{0.17em}}in\text{\hspace{0.17em}}watt/1\text{\hspace{0.17em}}milliwatt)\\ {P}_{dBm}=10\mathrm{log}10(0.5/10^-3)\end{array}$$

Here, the power equals 26.9897 dBm. For this reason, the two tones at 5 kHz and 10 kHz in the spectrogram have a color corresponding to 26.9897 dBm.

For a white noise signal, the spectrum is flat for all frequencies.
The spectrogram in this example shows a one sided spectrum in the
range [0 Fs/2]. For a white noise signal with a variance of 1e-4,
the power per unit bandwidth (P_{unitbandwidth})
is 1e-4. The total power in watts over the entire frequency range
is:

$$\begin{array}{l}{P}_{whitenoise}={P}_{unitbandwidth}*number\text{\hspace{0.17em}}of\text{\hspace{0.17em}}frequency\text{\hspace{0.17em}}bins,\\ {P}_{whitenoise}=({10}^{-4})*\left(\frac{Fs/2}{RBW}\right),\\ {P}_{whitenoise}=({10}^{-4})*\left(\frac{22050}{21.53}\right)\end{array}$$

The number of frequency bins is the ratio of total bandwidth to RBW. For a one-sided spectrum, the total bandwidth is half the sampling rate. RBW in this example is 21.53 Hz. With all these values, total power of white noise is -39.87 dBm.

When you run the model and do not see the spectrogram colors,
click the **Scale Color Limits**
button. This option autoscales
the colors.

The spectrogram updates in real time. During simulation, if you change any of the tunable parameters in the model, the changes are effective immediately in the spectrogram.

Was this topic helpful?