Main Content

wpspectrum

Wavelet packet spectrum

    Description

    [spec,times,freq] = wpspectrum(wpt,fs) returns a matrix of wavelet packet spectrum estimates, spec, for the binary wavelet packet tree object, wpt. fs is the sampling frequency in hertz. times is a vector of times and freq is a vector of frequencies.

    example

    [___] = wpspectrum(wpt,fs,'plot') displays the wavelet packet spectrum.

    [___,tinfo] = wpspectrum(___) returns the terminal nodes of the wavelet packet tree in frequency order.

    Examples

    collapse all

    Create a signal consisting of two sinusoids with disjoint support. The sinusoids have frequencies of 16 Hz and 64 Hz. Sample the signal at 500 Hz for 4 seconds.

    fs = 500;
    frA = 16;
    frB = 64;
    t = 0:1/fs:4;
    sig = sin(frA*2*pi*t).*(t<2) + sin(frB*2*pi*t).*(t>=2);
    plot(t,sig)
    axis tight
    title('Analyzed Signal')
    xlabel('Time (s)')

    Figure contains an axes object. The axes object with title Analyzed Signal contains an object of type line.

    Obtain the wavelet packet tree object corresponding to the level 6 wavelet packet decomposition of the signal using the sym6 wavelet.

    level = 6;
    wname = 'sym6';
    wpt = wpdec(sig,level,wname);

    Obtain and plot the wavelet packet spectrum.

    [S,T,F] = wpspectrum(wpt,fs,'plot');

    Figure contains an axes object. The axes object with title Wavelet packet decomposition contains 67 objects of type line, image, text.

    Generate a chirp signal sampled at 1000 Hz for 2 seconds.

    fs = 1000;
    t = 0:1/fs:2;       
    sig = sin(256*pi*t.^2);
    plot(t,sig)
    axis tight
    title('Analyzed Signal')
    xlabel('Time (s)')

    Figure contains an axes object. The axes object with title Analyzed Signal contains an object of type line.

    Obtain the wavelet packet tree object corresponding to the level 6 wavelet packet decomposition of the signal using the sym8 wavelet. Plot the wavelet packet spectrum.

    level = 6;
    wpt = wpdec(sig,level,'sym8');
    [S,T,F] = wpspectrum(wpt,fs,'plot');

    Figure contains an axes object. The axes object with title Wavelet packet decomposition contains 67 objects of type line, image, text.

    Input Arguments

    collapse all

    Binary wavelet packet tree, specified as a wavelet packet tree object.

    Sampling frequency in hertz, specified as a positive scalar.

    Data Types: double

    Output Arguments

    collapse all

    Wavelet packet spectrum estimates, returned as a matrix. spec is a 2J-by-N matrix, where J is the level of the wavelet packet transform, and N is the length of the time series. N is equal to the length of node 0 in the wavelet packet tree object.

    The frequency spacing between the rows of spec is fs/2J+1.

    Data Types: double

    Times, returned as a 1-by-N vector, where N is the length of the time series. The time spacing between elements is 1/fs.

    Data Types: double

    Frequencies, returned as a 1-by-2J vector, where J is the level of the wavelet packet transform. The frequency spacing in freq is fs/2J+1.

    Data Types: double

    Terminal nodes of the wavelet packet tree object in frequency order.

    Data Types: double

    More About

    collapse all

    Wavelet Packet Spectrum

    The wavelet packet spectrum contains the absolute values of the coefficients from the frequency-ordered terminal nodes of the input binary wavelet packet tree. The terminal nodes provide the finest level of frequency resolution in the wavelet packet transform.

    If J denotes the level of the wavelet packet transform and Fs is the sampling frequency, the terminal nodes approximate bandpass filters of the form:

    [nFs2J+1,(n+1)Fs2J+1)n=0,1,2,3,2J1

    At the terminal level of the wavelet packet tree, the transform divides the interval from 0 to the Nyquist frequency into bands of approximate width Fs/2J+1.

    Algorithms

    wpspectrum computes the wavelet packet spectrum as follows:

    • Extract the wavelet packet coefficients corresponding to the terminal nodes. Take the absolute value of the coefficients.

    • Order the wavelet packet coefficients by frequency ordering.

    • Determine the time extent on the original time axis corresponding to each wavelet packet coefficient. Repeat each wavelet packet coefficient to fill in the time gaps between neighboring wavelet packet coefficients and create a vector equal in length to node 0 of the wavelet packet tree object.

    References

    [1] Wickerhauser, M.V. Lectures on Wavelet Packet Algorithms, Technical Report, Washington University, Department of Mathematics, 1992.

    Introduced in R2010b