Maximal overlap discrete wavelet packet transform
The output of the MODWPT is time-delayed compared to the input signal. Most filters used to obtain the MODWPT have a nonlinear phase response, which makes compensating for the time delay difficult. This is true for all orthogonal scaling and wavelet filters, except the Haar wavelet. It is possible to time-align the coefficients with the signal features, but the result is an approximation, not an exact alignment with the original signal. The MODWPT partitions the energy among the wavelet packets at each level. The sum of the energy over all the packets equals the total energy of the input signal. The output of MODWPT is useful for applications where you want to analyze the energy levels in different packets.
The MODWPT details (
are the result of zero-phase filtering of the signal. The features
in the MODWPT details align exactly with features in the input signal.
For a given level, summing the details for each sample returns the
exact original signal. The output of the MODWPT details is useful
for applications that require time-alignment, such as nonparametric
MODWPT Using Default Wavelet
Obtain the MODWPT of an electrocardiogram (ECG) signal using the default length 18 Fejer-Korovkin (
load wecg; wpt = modwpt(wecg);
wpt is a 16-by-2048 matrix containing the sequency-ordered wavelet packet coefficients for the wavelet packet transform nodes. In this case, the nodes are at level 4. Each node corresponds to an approximate passband filtering of , where n = 0,...,15, and is the sampling frequency. Plot the wavelet packet coefficients at node (4,2), which is level 4, node 2.
plot(wpt(3,:)) title('Node 4 Wavelet Packet Coefficients')
MODWPT Using Daubechies Extremal Phase Wavelet with Two Vanishing Moments
Obtain the MODWPT of Southern Oscillation Index data with the Daubechies extremal phase wavelet with two vanishing moments (
load soi; wsoi = modwpt(soi,'db2');
Verify that the size of the resulting transform contains 16 nodes. Each node is in a separate row.
ans = 1×2 16 12998
MODWPT Full Packet Tree and Passband Center Frequencies
Obtain the MODWPT and full wavelet packet tree of an ECG waveform using the default length 18 Fejer-Korovkin (
'fk18') wavelet. Extract and plot the node coefficients at level 3, node 2.
load wecg; [wpt,packetlevels,cfreq] = modwpt(wecg,'FullTree',true); p3 = wpt(packetlevels==3,:); plot(p3(3,:)) title('Level 3, Node 2 Wavelet Coefficients')
Display the center frequencies at level 3.
ans = 8×1 0.0312 0.0938 0.1562 0.2188 0.2812 0.3438 0.4062 0.4688
MODWPT Energy and Relative Energy
Obtain and plot the MODWPT energy and relative energy of an ECG waveform.
load wecg [wpt,~,cfreq,energy,relenergy] = modwpt(wecg);
Show that the sum of the MODWPT energies is equal to the sum of the energy in the original signal. The difference between the total MODWPT energy and the signal energy is small enough to be considered insignificant.
disp(['Difference between MODWPT energy and signal energy: ',num2str(sum(energy)-sum(wecg.^2))])
Difference between MODWPT energy and signal energy: 3.6122e-09
Plot the MODWPT energy by node.
figure bar(1:16,energy) xlabel('Node') ylabel('Energy') title('Energy by Node')
disp(['Total power in passband: ',num2str(energy(1))])
Total power in passband: 200.8446
Plot the relative energy and show the percentage of signal energy in the first passband [0,5.6250].
figure bar(1:16,relenergy*100) xlabel('Node') ylabel('Percent Energy') title('Energy Relative to Signal Energy by Node')
disp(['Percentage of signal power in passband: ',num2str(relenergy(1)*100)])
Percentage of signal power in passband: 67.3352
Obtain the time-aligned MODWPT of two intermittent sine waves in noise. The sine wave frequencies are 150 Hz and 200 Hz. The data is sampled at 1000 Hz.
dt = 0.001; t = 0:dt:1-dt; x = cos(2*pi*150*t).*(t>=0.2 & t<0.4)+ sin(2*pi*200*t).*(t>0.6 & t<0.9); y = x+0.05*randn(size(t)); [wpta,~,Falign] = modwpt(x,'TimeAlign',true); [wptn,~,Fnon] = modwpt(x);
Compare the nonaligned and time-aligned time-frequency plots.
subplot(2,1,1); contour(t,Fnon.*(1/dt),abs(wptn).^2); grid on; ylabel('Hz'); title('Time-Frequency Plot (Nonaligned)'); subplot(2,1,2) contour(t,Falign.*(1/dt),abs(wpta).^2); grid on; xlabel('Time'); ylabel('Hz'); title('Time-Frequency Plot (Aligned)');
x — Input signal
Input signal, specified as a real-valued row or column vector.
have at least two elements.
wname — Analyzing wavelet
"fk18" (default) | character vector | string scalar | ...
Analyzing wavelet, specified as a character vector or string scalar. The
wavelet must be orthogonal. Orthogonal wavelets are designated as type 1
wavelets in the wavelet manager,
Valid built-in orthogonal wavelet families are: Best-localized Daubechies
"bl"), Beylkin (
"coif"), Daubechies (
"fk"), Haar (
Han linear-phase moments (
"sym"), and Vaidyanathan
For a list of wavelets in each family, see
wfilters. You can also use
waveinfo with the
wavelet family short name. For example,
wname is orthogonal (returns 1). For
wavemngr("type","db6") returns 1.
lo,hi — Filters
even-length real-valued vectors
Filters, specified as a pair of even-length real-valued vectors.
lo is the orthogonal scaling filter and
hi is the orthogonal wavelet filter. The filters must
satisfy the conditions for an orthogonal wavelet. For more information, see
isorthwfb. You cannot specify both
wname and a filter pair
By default, the
returns two pairs of filters associated with an orthogonal or
biorthogonal wavelet you specify. To agree with the usual convention
in the implementation of
MODWPT in numerical
packages, when you specify an orthogonal wavelet
function internally uses the second pair of filters returned by
is equivalent to
[~,~,lo,hi] = wfilters("db2"); wpt =
This convention is different from the one followed by most Wavelet Toolbox™ discrete wavelet transform functions when decomposing a signal. Most functions internally use the first pair of filters.
lev — Transform level
Transform level, specified as a positive integer less than or
Specify optional pairs of arguments as
the argument name and
Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name in quotes.
'Fulltree',true returns the full
wavelet packet tree
FullTree — Full packet tree
false (default) |
Option to return the full wavelet packet tree, specified as
the comma-separated pair consisting of
true. If you
only the terminal (final-level) wavelet packet nodes. If you specify
modwpt returns the full wavelet packet tree
down to the specified level.
TimeAlign — Signal time alignment
false (default) |
Option to time align wavelet packet coefficients with signal
features, specified as the comma-separated pair consisting of
true to time align or
The scaling and wavelet filters have a time delay. Circularly
shifting the wavelet packet coefficients in all nodes aligns the signal
and wavelet coefficients in time. If you want to reconstruct the signal,
such as by using
do not shift the coefficients because time alignment is done during
the inversion process.
wpt — Wavelet packet transform
Wavelet packet tree, returned as a matrix with each row containing
the sequency-ordered wavelet packet coefficients. By default,
only the terminal level for the MODWPT. The default terminal level
is either level 4 or
is smaller. At level 4,
wpt is a 16-by-
matrix. For the full tree, at level j,
matrix, with each row containing the packet coefficients by level
and index. The approximate passband for the nth
wpt at level j is cycles/sample,
where n = 1,2,...2j.
packetlevs — Transform levels
Transform levels, returned as a vector. The levels correspond
to the rows of
only the terminal level coefficients,
a vector of constants equal to the terminal level. If
the full wavelet packet table,
a vector with 2j elements
for each level, j. To select all the wavelet packet
nodes at a particular level, use
cfreq — Center frequencies of passbands
Center frequencies of the approximate passbands in the
returned as a vector. The center frequencies are in cycles/sample.
To convert the units to cycles/unit time, multiply
the sampling frequency.
energy — Energy of the wavelet packet coefficients
Energy of the wavelet packet coefficients for the
returned as a vector. The sum of the energies (squared L2 norms) for
the wavelet packets at each level equals the energy in the signal.
relenergy — Relative energy
Relative energy for each level, returned as a vector. The relative energy is the proportion of energy in each wavelet packet by level, relative to the total energy of that level. The sum of relative energies in all packets at each level equals 1.
modwpt performs a discrete wavelet
packet transform and produces a sequency-ordered wavelet packet tree.
Compare the sequency-ordered and normal (Paley)-ordered trees.
 Percival, D. B., and A. T. Walden. Wavelet Methods for Time Series Analysis. Cambridge, UK: Cambridge University Press, 2000.
 Walden, A.T., and A. Contreras Cristan. “The phase-corrected undecimated discrete wavelet packet transform and its application to interpreting the timing of events.” Proceedings of the Royal Society of London A. Vol. 454, Issue 1976, 1998, pp. 2243-2266.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
wnamemust be constant.
Introduced in R2016a