Main Content

Compute Signal Spectrum Using Different Windows

Read an audio recording of an electronic toothbrush into MATLAB®. The signal is sampled at 48 kHz. The toothbrush turns on at about 1.75 seconds and stays on for approximately 2 seconds.

[y,fs] = audioread("toothbrush.m4a");

Open Signal Analyzer and drag the signal from the Workspace Browser to the Signal table. Add time information to the signal by selecting it in the Signal table and clicking Time Values on the Analyzer tab. Select Sample Rate and Start Time and enter fs for the sample rate.

On the Display tab, click Display Grid to create a two-by-two grid of displays. Select each display, click Spectrum to add a spectrum view, and click Time to remove the time view. Drag the signal to all four displays.

Signal Analyzer app, showing the Display strip, from which the Spectrum view is selected. The app also shows the signal "y" in frequency domain in a 2-by-2 grid of displays. The four displays show the same spectrum for "y".

Click the Spectrum tab to modify the spectrum view in each display.

  1. Click the top left display to select it. Move the Leakage slider until you get a leakage value of 32.

  2. Click the top right display to select it. On the Resolution Type section, select Window Length. On the Window Length section, select Specify and specify a window length of 1500 samples. On the Window Options section, choose a Rectangular window and specify an overlap percentage of 20.

  3. Click the bottom left display to select it. On the Resolution Type section, select Window Length. On the Window Length section, select Specify and specify a window length of 500 samples. On the Window Options section, choose a Hamming window and specify an overlap percentage of 50. On the NFFT section, specify 550 discrete Fourier transform points.

  4. Click the bottom right display to select it. On the Resolution Type section, select Window Length. On the Window Length section, select Specify and specify a window length of 5000 samples. On the Window Options section, choose a Chebyshev window and specify a sidelobe attenuation of 50 dB and an overlap percentage of 90.

You can see that some views show higher resolution but higher leakage, while other views have lower leakage but at the expense of resolution.

Signal Analyzer app, showing the Display strip, from which the Spectrum view is selected. The app also shows the signal "y" in frequency domain in a 2-by-2 grid of displays. The four displays now show different spectra for "y", each of them modified with its own spectrum settings.

See Also

Apps

Functions

Related Examples

More About