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.
Click the Spectrum tab to modify the spectrum view in each display.
Click the top left display to select it. Move the Leakage slider until you get a leakage value of 32.
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.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.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.
See Also
Apps
Functions
Related Examples
- Find Delay Between Correlated Signals
- Resolve Tones by Varying Window Leakage
- Find Interference Using Persistence Spectrum
- Modulation and Demodulation Using Complex Envelope
- Find and Track Ridges Using Reassigned Spectrogram
- Extract Voices from Music Signal
- Resample and Filter a Nonuniformly Sampled Signal
- Declip Saturated Signals Using Your Own Function
- Compute Envelope Spectrum of Vibration Signal
- Extract Regions of Interest from Whale Song
More About
- Use Signal Analyzer App
- Edit Sample Rate and Other Time Information
- Data Types Supported by Signal Analyzer
- Spectrum Computation in Signal Analyzer
- Persistence Spectrum in Signal Analyzer
- Spectrogram Computation in Signal Analyzer
- Scalogram Computation in Signal Analyzer
- Keyboard Shortcuts for Signal Analyzer
- Signal Analyzer Tips and Limitations