## Spectrum Computation in Signal Analyzer

When computing the spectrum of a signal, the ability to resolve frequency components that are close to each other comes at the expense of the ability to detect weak components from noise. Signal Analyzer offers three options to balance those conflicting aims and achieve the best possible resolution for your application. The options are available in the Resolution Type section of the Spectrum tab.

Signal Analyzer scales the spectrum so that, if the frequency content of a signal falls exactly within a bin, its amplitude in that bin is the true average power of the signal. For example, the average power of a sinusoid is one-half the square of the sinusoid amplitude. For more details, see Measure Power of Deterministic Periodic Signals.

### Resolution and Leakage

Any real-world signal is measurable only for a finite length of time. This fact introduces nonnegligible effects into Fourier analysis, which assumes that signals are infinitely long. Spectral windowing, which consists of assigning different weights to different signal samples, deals systematically with finite-size effects.

The simplest approach is to assume that the signal is identically zero outside of the measurement interval and that all samples are equally significant. This approach is equivalent to using a rectangular window. The rectangular window has discontinuous jumps at both ends that result in spectral ringing. All other spectral windows taper at both ends to lessen this effect by assigning smaller weights to samples close to the signal edges.

The windowing process involves a compromise between conflicting aims: improving resolution and decreasing leakage.

• Resolution is the ability to know precisely how the signal energy is distributed in the frequency space. A spectrum analyzer with ideal resolution can distinguish two different tones (pure sinusoids) present in the signal, no matter how close in frequency. For non-ideal analyzers, the resolution bandwidth measures how close two tones can be and still be resolved.

• Leakage is the fact that, in a finite signal, every frequency component projects energy content throughout the complete frequency span. You can measure the amount of leakage in a spectrum by the ability to detect a weak tone from noise in the presence of a neighboring strong tone.

Note

• The better the resolution, the higher the leakage. A window with narrow mainlobe but low sidelobe attenuation can resolve closely spaced tones with similar energy content but fails to find a weaker tone in the presence of a neighboring strong tone.

• The lower the leakage, the worse the resolution. A window with high sidelobe attenuation but wide mainlobe is able to detect weak tones but smears close frequencies together.

### Welch Periodogram

In most cases, Signal Analyzer computes the spectrum of a signal using a Welch periodogram. The app:

1. Divides the signals into overlapping segments. The stride length is the distance between initial samples of consecutive segments. The overlap between adjoining segments is the segment length minus the stride length.

2. Windows each segment separately. The window length is the length of each segment.

3. Computes the periodogram of each segment over a set of NFFT discrete Fourier transform points.

4. Averages the periodograms of all the segments.

Welch’s procedure is designed to reduce the variance of the spectrum estimate by averaging different “realizations” of the signal and using the window to remove redundant data. See `pwelch` for more details.

### Control Leakage

If you select Leakage in the Resolution Type section of the Spectrum tab, Signal Analyzer initially determines the type of spectrum to compute based on the resolution bandwidth.

• The resolution bandwidth has a theoretical value of

`${\text{RBW}}_{\text{theory}}=\frac{\text{ENBW}}{{t}_{\mathrm{max}}-{t}_{\mathrm{min}}}.$`

• ENBW is the equivalent noise bandwidth of the spectral window. Use the Leakage slider in the Spectrum tab to control the ENBW. For more details, see `enbw`.

• tmax – tmin, the record length, is the time-domain duration of the selected signal region. To select and adjust the record length or region of interest, use the panner, zoom in on the time-domain plot, or change the limits on the Time tab.

Note

• If you zoom in on a region of a signal spectrum using one of the zoom actions on the Display tab, the app does not change the resolution bandwidth. Instead, Signal Analyzer performs an optical zooming, using bandlimited interpolation to display a smooth spectral curve.

• If the selected time interval extends beyond the ends of a signal, Signal Analyzer zero-pads the signal. If a signal has no samples within the selected time interval, the app displays nothing.

• In practice, the app might lower the resolution to compute the spectrum in a reasonable amount of time and to display it with a finite number of pixels. The lowest resolution bandwidth the app can use is

`${\text{RBW}}_{\text{performance}}=\frac{{f}_{\text{span}}}{4096-1},$`

where fspan is the width of the frequency range specified by setting Frequency Limits values on the Spectrum tab. If you do not specify a frequency range, the app uses the maximum sample rate from all the signals in the display for the value of fspan.

Note

To compute the spectrum of a signal, the app chooses the larger of the two values: $\text{RBW}=\mathrm{max}\left({\text{RBW}}_{\text{theory}},{\text{RBW}}_{\text{performance}}\right).$ The app displays the actual resolution bandwidth in the Frequency Resolution section of the Spectrum tab.

• If the resolution bandwidth is RBWtheory, then Signal Analyzer computes a single modified periodogram for the whole signal over NFFT = 4096 discrete Fourier transform points. The app uses a Kaiser window with an adjustable shape factor and applies zero-padding when the time limits on the axes exceed the signal duration. See `periodogram` for more details.

• If the resolution bandwidth is RBWperformance, then Signal Analyzer computes a Welch periodogram of the signal.

#### Window Length

If you adjust the spectral resolution by controlling the leakage, Signal Analyzer chooses a window length

where max(fNyquist) is the highest Nyquist frequency among all the signals in the display. (If there is no aliasing, the Nyquist frequency is half the sample rate.)

Note

If no signals have time information, Signal Analyzer works in normalized frequencies. Using normalized frequencies is equivalent to specifying a sample rate of 2π.

#### Discrete Fourier Transform points

If you adjust the spectral resolution by controlling the leakage, Signal Analyzer computes the periodogram of each segment over NFFT = 4096 discrete Fourier transform points.

#### Window Type and Attenuation

If you adjust the spectral resolution by controlling the leakage, Signal Analyzer uses Kaiser windows, which have an adjustable shape factor β that is related to the leakage by β = 40(1 – ).

• The minimum value in the slider range corresponds to a Kaiser window with β = 40, where a wide mainlobe captures essentially all the spectral energy representable in double precision and the energy contained in the sidelobes becomes negligible.

• An intermediate value of β ≈ 6 approximates a Hann window closely.

• The maximum value in the slider range corresponds to a Kaiser window with β = 0, equivalent to a rectangular window with a narrow mainlobe and large sidelobes.

Choosing a β value is equivalent to specifying the sidelobe attenuation of the window. If α is the attenuation in dB, the two quantities are related by

`$\beta =\left\{\begin{array}{ll}0.1102\left(\alpha -8.7\right),\hfill & \alpha >50\hfill \\ 0.5842{\left(\alpha -21\right)}^{0.4}+0.07886\left(\alpha -21\right),\hfill & 50\ge \alpha \ge 21\hfill \\ 0,\hfill & \alpha <21\hfill \end{array}$`

#### Overlap

Signal Analyzer makes an initial estimate of the stride length using

corresponding to an overlap percent of

`$\left(1-\frac{\text{1}}{2×\text{ENBW}-1}\right)×100,$`

and adjusts it so that the first window starts exactly on the first sample of the first segment and the last window ends exactly on the last sample of the last segment. The number of segments depends on the window length and the overlap. The larger the overlap, the larger the number of segments.

### Control Resolution Bandwidth

Since R2023b

If you select RBW in the Resolution Type section of the Spectrum tab, Signal Analyzer computes a Welch periodogram of the signal. You can specify the RBW, the window type, the overlap between adjoining segments, and the sidelobe attenuation for some windows.

#### Window Length

• If you specify an RBW value in the Bandwidth section of the Spectrum tab, Signal Analyzer determines the window length iteratively by solving this equation:

• If you select in the Bandwidth section of the Spectrum tab, Signal Analyzer chooses a window length of N/d samples, where the brackets denote the ceiling function, N is the signal length, and d is a divisor that depends on N.

Signal Length (N)Divisor (d)Segment Length
`2` samples – `63` samples`2``1` sample – `32` samples
`64` samples – `255` samples`8``8` samples – `32` samples
`256` samples – `2047` samples`8``32` samples – `256` samples
`2048` samples – `4095` samples`16``128` samples – `256` samples
`4096` samples – `8191` samples`32``128` samples – `256` samples
`8192` samples – `16383` samples`64``128` samples – `256` samples
`16384` samples – N samples`128``128` samples – ⌈N / `128`⌉ samples

#### Discrete Fourier Transform Points

If you adjust the spectral resolution by controlling the resolution bandwidth, Signal Analyzer always makes NFFT equal to the window length.

#### Window Type and Attenuation

If you adjust the spectral resolution by controlling the resolution bandwidth, you can choose one of these spectral windows:

• Blackman-Harris

• Chebyshev

• Flat-top

• Hamming (default)

• Hann

• Kaiser

• Rectangular

You can control the sidelobe attenuation for the Chebyshev and Kaiser windows. Specify the desired attenuation as a positive number in decibels.

• For a Chebyshev window, all sidelobes have an amplitude smaller than the mainlobe level by the specified attenuation value. The specified value must be at least 45 dB.

• For a Kaiser window, the highest sidelobe has an amplitude smaller than the mainlobe level by the specified attenuation value. The specified value must be at least 21 dB. Choosing a sidelobe attenuation of α dB is equivalent to specifying this β value:

`$\beta =\left\{\begin{array}{ll}0.1102\left(\alpha -8.7\right),\hfill & \alpha >50\hfill \\ 0.5842{\left(\alpha -21\right)}^{0.4}+0.07886\left(\alpha -21\right),\hfill & 50\ge \alpha \ge 21\hfill \\ 0,\hfill & \alpha <21\hfill \end{array}$`

#### Overlap

You can specify the window length and the overlap between adjoining segments simultaneously. Specifying the overlap changes the number of segments. The larger the overlap, the larger the number of segments. Segments that extend beyond the signal endpoint are zero-padded.

For example, consider the seven-sample signal ```[s0 s1 s2 s3 s4 s5 s6]``` and a window length of 4 samples.

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```

Specify the overlap value as a percentage of the window length. The default value is 50%.

Note

You cannot specify 100% overlap. The maximum attainable value corresponds to one sample less than the window length. If you specify that value, Signal Analyzer divides the signal into [Signal length – (Window length – 1)] segments.

### Control Window Length

Since R2023b

If you select Window Length in the Resolution Type section of the Spectrum tab, Signal Analyzer computes a Welch periodogram of the signal. You can specify the window length, the number of discrete Fourier transform points, the window type, the overlap between adjoining segments, and the sidelobe attenuation for some windows.

#### Window Length

Specify the window length in samples. If you select Auto in the Bandwidth section of the Spectrum tab, Signal Analyzer uses a window length

so that the signal is divided into eight segments with ⌊Window length × Overlap percent/100⌋ samples of overlap between adjoining segments. The ⌊⌋ symbols denote the floor function.

#### Discrete Fourier Transform Points

If you adjust the spectral resolution by controlling the window length, you can specify NFFT. NFFT must be greater than or equal to the window length. If you do not specify a value, Signal Analyzer uses the window length.

#### Window Type and Attenuation

If you adjust the spectral resolution by controlling the window length, you can choose one of these spectral windows:

• Blackman-Harris

• Chebyshev

• Flat-top

• Hamming (default)

• Hann

• Kaiser

• Rectangular

You can control the sidelobe attenuation for the Chebyshev and Kaiser windows. Specify the desired attenuation as a positive number in decibels.

• For a Chebyshev window, all sidelobes have an amplitude smaller than the mainlobe level by the specified attenuation value. The specified value must be at least 45 dB.

• For a Kaiser window, the highest sidelobe has an amplitude smaller than the mainlobe level by the specified attenuation value. The specified value must be at least 21 dB. Choosing a sidelobe attenuation of α dB is equivalent to specifying this β value:

`$\beta =\left\{\begin{array}{ll}0.1102\left(\alpha -8.7\right),\hfill & \alpha >50\hfill \\ 0.5842{\left(\alpha -21\right)}^{0.4}+0.07886\left(\alpha -21\right),\hfill & 50\ge \alpha \ge 21\hfill \\ 0,\hfill & \alpha <21\hfill \end{array}$`

#### Overlap

You can specify the window length and the overlap between adjoining segments simultaneously. Specifying the overlap changes the number of segments. The larger the overlap, the larger the number of segments. The app zero-pads segments that extend beyond the signal endpoint.

For example, consider the seven-sample signal ```[s0 s1 s2 s3 s4 s5 s6]``` and a window length of 4 samples.

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```

Specify the overlap value as a percentage of the window length. The default value is 50%.

Note

You cannot specify 100% overlap. The maximum attainable value corresponds to one sample less than the window length. If you specify that value, Signal Analyzer divides the signal into [Signal length – (Window length – 1)] segments.

## References

[1] harris, fredric j. “On the Use of Windows for Harmonic Analysis with the Discrete Fourier Transform.” Proceedings of the IEEE®. Vol. 66, January 1978, pp. 51–83.

[2] Welch, Peter D. “The Use of Fast Fourier Transform for the Estimation of Power Spectra: A Method Based on Time Averaging Over Short, Modified Periodograms.” IEEE Transactions on Audio and Electroacoustics. Vol. 15, June 1967, pp. 70–73.

[3] Oppenheim, Alan V., and Ronald W. Schafer, with John R. Buck. Discrete-Time Signal Processing. Upper Saddle River, NJ: Prentice Hall, 1999.