Documentation

This is machine translation

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

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.

Spectrogram Computation in Signal Analyzer

A nonstationary signal is a signal whose frequency content changes with time. The spectrogram of a nonstationary signal is an estimate of the time evolution of its frequency content. To construct the spectrogram of a nonstationary signal, Signal Analyzer follows these steps:

  1. Divide the signal into equal-length segments. The segments must be short enough that the frequency content of the signal does not change appreciably within a segment. The segments may or may not overlap.

  2. Window each segment and compute its spectrum to get the short-time Fourier transform.

  3. Display segment-by-segment the power of each spectrum in decibels. Depict the magnitudes side-by-side as an image with magnitude-dependent colormap.

The spectrogram view is available in displays that contain only one signal.

Divide Signal into Segments

To construct a spectrogram, first divide the signal into possibly overlapping segments. In Signal Analyzer, you can control the length of the segments and the amount of overlap between adjoining segments using Time Resolution and Overlap. If you do not specify the length and overlap, Signal Analyzer chooses a length based on the entire length of the signal, and 50% overlap. The app aligns the time axis of the spectrogram with the axis of the time-domain plot.

Specified Time Resolution

On the Spectrogram tab, in the Time Resolution section, click Specify.

  • If the signal does not have time information, specify the time resolution (segment length) in samples. The time resolution must be an integer greater than or equal to 1 and smaller than or equal to the signal length.

    If the signal has time information, specify the time resolution in seconds. The app converts the result into a number of samples and rounds it to the nearest integer that is less than or equal to the number but not smaller than 1. The time resolution must be smaller than or equal to the signal duration.

  • Specify the overlap as a percentage of the segment length. The app converts the result into a number of samples and rounds it to the nearest integer that is less than or equal to the number.

Default Time Resolution

If you select Auto for the time resolution computation, then Signal Analyzer uses the length of the entire signal to choose the length of the segments. The app sets the time resolution as

Nd

samples, where the brackets denote the ceiling function, N is the length of the signal, and d is a divisor that depends on N:

Signal Length (N)Divisor (d)Segment Length
2 samples – 63 samples21 sample – 32 samples
64 samples – 255 samples88 samples – 32 samples
256 samples – 2047 samples832 samples – 256 samples
2048 samples – 4095 samples16128 samples – 256 samples
4096 samples – 8191 samples32128 samples – 256 samples
8192 samples – 16383 samples64128 samples – 256 samples
16384 samples – N samples128128 samples – ⌈N / 128⌉ samples

You can still specify the overlap between adjoining segments. Specifying the overlap changes the number of segments. Segments that extend beyond the signal endpoint are zero-padded.

Consider the seven-sample signal [s0 s1 s2 s3 s4 s5 s6]. Because ⌈7/2⌉ = ⌈3.5⌉ = 4, the app divides the signal into two segments of length four when there is no overlap. The number of segments changes as the overlap increases.

Number of Overlapping SamplesResulting Segments
0
s0 s1 s2 s3
            s4 s5 s6 0
1
s0 s1 s2 s3
         s3 s4 s5 s6
2
s0 s1 s2 s3
      s2 s3 s4 s5
            s4 s5 s6 0
3
s0 s1 s2 s3
   s1 s2 s3 s4
      s2 s3 s4 s5
         s3 s4 s5 s6

Time Alignment

Once the segment length and overlap are set, the number of segments and their edge locations stay fixed and are independent of any zooming or panning. When you zoom and pan, the app computes and displays the spectrogram using the segments that fall within the visible zoomed-in region of interest.

The app:

  • Aligns the time axis of the spectrogram with the axis of the corresponding time-domain plot. That way, the spectral content at a given time aligns with its occurrence.

  • For nonzero overlap, extends the first and last segments to the signal endpoints.

  • Zero-pads the signal if the last segment extends beyond the signal endpoint.

When the segments have 0% overlap, each segment is centered at the actual time of occurrence. When the overlap is nonzero, the alignment of the spectrogram time axis with the time-domain axis has the effect that the first and last time intervals are elongated. All other time intervals are of the same length. In other words, the center of each segment, except for the first and last, corresponds to the actual time of occurrence. Consider this example:

Window the Segments and Compute Spectra

After Signal Analyzer divides the signal into overlapping segments, the app windows each segment with a Kaiser window. The shape factor β of the window, and therefore the leakage, is adjustable.

Note

The leakage used to compute the signal spectrum and the leakage used to window the spectrogram segments are independent of each other. You can adjust them separately.

The app then computes the spectrum of each segment, using the procedure outlined in Spectrum Computation in Signal Analyzer. In summary, Signal Analyzer finds a compromise between the spectral resolution achievable with the entire length of the segment and the performance limitations that result from computing large FFTs.

  • If the resolution resulting from analyzing the full segment is achievable, the app computes a single modified periodogram of the whole segment using a Kaiser window with the specified shape factor.

  • If the resolution resulting from analyzing the full segment is not achievable, the app computes a Welch periodogram: It divides the segment into overlapping subsegments, windows each subsegment, and averages the periodograms of the subsegments. The app chooses the subsegment size, the window, and the overlap so that the composite periodogram is equivalent to a modified periodogram of the whole segment with the specified Kaiser window.

Display Spectrum Power

The app displays the power of the short-time Fourier transform in decibels, using a color bar with the default MATLAB® colormap. The color bar comprises the full power range of the spectrogram and does not change if you zoom or pan.

You can change the magnitude levels represented by a given color range. On the Spectrogram tab, change the minimum and maximum power values to display. You can also set the colormap so that it comprises the full power range of the zoomed-in section of the spectrogram. On the Display tab, click the scale color button .

See Also

Apps

Functions

Related Examples

More About

Was this topic helpful?