Main Content

wpcoef

Wavelet packet coefficients

    Description

    wpcoef is a one- or two-dimensional wavelet packet analysis function.

    x = wpcoef(wpt,n) returns the coefficients associated with the node n of the wavelet packet tree wpt. If node n does not exist, x = [].

    example

    x = wpcoef(wpt) is equivalent to x = wpcoef(wpt,0).

    Examples

    collapse all

    Load a 1-D signal. Save the current extension mode.

    load noisdopp
    x = noisdopp;
    origMode = dwtmode("status","nodisp");

    Use dwtmode to change the extension mode to zero-padding. Obtain the wavelet packet tree object corresponding to the 3-level wavelet packet decomposition of the signal using the db1 wavelet. Plot the tree.

    dwtmode("zpd","nodisp")
    wpt = wpdec(x,3,"db1");
    plot(wpt)

    Figure contains 2 axes objects and other objects of type uimenu. Axes object 1 with title Tree Decomposition contains 29 objects of type line, text. Axes object 2 with title data for node: 0 or (0,0). contains an object of type line.

    Obtain the coefficients at the node (3,0). Plot the signal and coefficients.

    cfs = wpcoef(wpt,[3 0]);
    tiledlayout(2,1)
    nexttile
    plot(x)
    title("Signal")
    axis tight
    nexttile
    plot(cfs)
    title("Packet (3,0) Coefficients")
    axis tight

    Figure contains 2 axes objects. Axes object 1 with title Signal contains an object of type line. Axes object 2 with title Packet (3,0) Coefficients contains an object of type line.

    Load an image. Obtain the wavelet packet tree that corresponds to a one-level wavelet packet decomposition of the image using the sym4 wavelet.

    load mask
    t = wpdec2(X,1,"sym4");

    Plot the tree.

    plot(t)

    Figure contains 2 axes objects and other objects of type uimenu. Axes object 1 with title Tree Decomposition contains 9 objects of type line, text. Axes object 2 with title data for node: 0 or (0,0). contains an object of type image.

    Obtain the coefficients at the node (1,0). Plot the coefficients.

    cfs = wpcoef(t,[1 0]);
    figure
    imagesc(cfs)
    colormap(pink)
    title("Packet (1,0) Coefficients")

    Figure contains an axes object. The axes object with title Packet (1,0) Coefficients contains an object of type image.

    Restore the extension mode to the original setting.

    dwtmode(origMode,"nodisp")

    Input Arguments

    collapse all

    Wavelet packet tree, specified as a wptree object.

    Node in a wavelet packet tree, specified as a nonnegative integer, or pair of nonnegative integers. See depo2ind and ind2depo.

    Example: If wpt = wpdec(1:256,2,"sym4"), then wpcoef(wpt,3) and wpcoef(wpt,[2 0]) specify the same node.

    Data Types: double

    Output Arguments

    collapse all

    Node coefficients, returned as a vector or matrix.

    Data Types: double

    Version History

    Introduced before R2006a