Maximal overlap discrete wavelet transform
maximal overlap discrete wavelet transform (MODWT) of
w = modwt(
x can be a real- or complex-valued vector or matrix. If
x is a matrix,
modwt operates on the
modwt computes the wavelet
transform down to level
x is a vector and
x is a matrix. By default,
the Daubechies least-asymmetric wavelet with four vanishing moments
'sym4') and periodic boundary handling.
MODWT using reflection boundary handling. Other inputs can be any of the arguments
from previous syntaxes. Before computing the wavelet transform,
w = modwt(___,'reflection')
modwt extends the signal symmetrically at the terminal end
to twice the signal length. The number of wavelet and scaling coefficients that
modwt returns is equal to twice the length of the input
signal. By default, the signal is extended periodically.
You must enter the entire character vector
'reflection'. If you
added a wavelet named
'reflection' using the wavelet manager, you
must rename that wavelet prior to using this option.
may be placed in any position in the input argument list after
MODWT Using Default Wavelet
Obtain the MODWT of an electrocardiogram (ECG) signal using the default
sym4 wavelet down to the maximum level. The data are taken from Percival & Walden (2000), p.125 (data originally provided by William Constantine and Per Reinhall, University of Washington).
load wecg; wtecg = modwt(wecg); whos wtecg
Name Size Bytes Class Attributes wtecg 12x2048 196608 double
The first eleven rows of
wtecg are the wavelet coefficients for scales to . The final row contains the scaling coefficients at scale . Plot the detail (wavelet) coefficients for scale .
plot(wtecg(3,:)) title('Level 3 Wavelet Coefficients')
MODWT Using Daubechies Extremal Phase Wavelet with Two Vanishing Moments
Obtain the MODWT of Southern Oscillation Index data with the
db2 wavelet down to the maximum level.
load soi; wsoi = modwt(soi,'db2');
MODWT Using Scaling and Wavelet Filters
Obtain the MODWT of the Deutsche Mark - U.S. Dollar exchange rate data using the Fejér-Korovkin length 8 scaling and wavelet filters.
load DM_USD [~,~,Lo,Hi] = wfilters("fk8"); wdmf = modwt(DM_USD,Lo,Hi);
Obtain a second MODWT with the same wavelet, but this time specify the wavelet name.
wdmn = modwt(DM_USD,"fk8");
Confirm the decompositions are equal.
ans = 0
MODWT to a Specified Level
Obtain the MODWT of an ECG signal down to scale , which corresponds to level four. Use the default
sym4 wavelet. The data are taken from Percival & Walden (2000), p.125 (data originally provided by William Constantine and Per Reinhall, University of Washington).
load wecg; wtecg = modwt(wecg,4); whos wecg wtecg
Name Size Bytes Class Attributes wecg 2048x1 16384 double wtecg 5x2048 81920 double
The row size of
wtecg is L+1, where, in this case, the level (L) is 4. The column size matches the number of input samples.
MODWT with Reflection Boundary
Obtain the MODWT of an ECG signal using reflection boundary handling. Use the default
sym4 wavelet and obtain the transform down to level 4. The data are taken from Percival & Walden (2000), p.125 (data originally provided by William Constantine and Per Reinhall, University of Washington).
load wecg; wtecg = modwt(wecg,4,'reflection'); whos wecg wtecg
Name Size Bytes Class Attributes wecg 2048x1 16384 double wtecg 5x4096 163840 double
wtecg has 4096 columns, which is twice the length of the input signal,
Time Align MODWT Analysis
Create a unit impulse signal.
n = 128; sig = zeros(1,n); sig(n/2) = 1; clf plot(sig) axis tight title("Unit Impulse")
Obtain the MODWT of the signal down to level 4 using default
modwt settings. Obtain a second MODWT of the signal down to level 4 with the coefficients time aligned.
lev = 4; w = modwt(sig,lev); wTimeAligned = modwt(sig,lev,TimeAlign=true);
Plot the wavelet and scaling coefficients of the MODWT obtained with default settings. The delays increase with scale because the wavelet and scaling filters used in the MODWT have non-zero phase response.
for k=1:lev+1 subplot(lev+1,1,k) plot(w(k,:)) axis tight if k==1 title("MODWT Analysis with Delay") end end
Compare with plots of the time-aligned coefficients.
for k=1:lev+1 subplot(lev+1,1,k) plot(wTimeAligned(k,:)) axis tight if k==1 title("Time-Aligned MODWT Analysis") end end
MODWT of Multisignal
Load the 23 channel EEG data
Espiga3 . The channels are arranged column-wise. The data is sampled at 200 Hz.
Compute the maximal overlap discrete wavelet transform down to the maximum level.
wt = modwt(Espiga3);
Obtain the squared signal energies and compare them against the squared energies obtained from summing the wavelet coefficients over all levels. Use the log-squared energy due to the disproportionately large energy in one component.
sigN2 = vecnorm(Espiga3).^2; wtN2 = sum(squeeze(vecnorm(wt,2,2).^2)); bar(1:23,log(sigN2)) hold on scatter(1:23,log(wtN2),'filled','SizeData',100) alpha(0.75) legend('Signal Energy','Energy in Wavelet Coefficients', ... 'Location','NorthWest') xlabel('Channel') ylabel('ln(squared energy)')
x — Input signal
vector | matrix
Input signal, specified as a vector or matrix. If
is a vector,
x must have at least two elements. If
x is a matrix, the row dimension of
x must be at least 2.
Complex Number Support: Yes
wname — Wavelet
"sym4" (default) | character vector | string scalar
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,
wavemngr("type",wn) to determine
if the wavelet wn is orthogonal (returns 1). For example,
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 scaling filter, and
is the wavelet filter. The filters must satisfy the conditions for an
orthogonal wavelet. The lengths of
Hi must be equal. See
wfilters for additional
information. You cannot specify both
wname and a filter
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
MODWT in numerical
packages, when you specify an orthogonal wavelet
function internally uses the second pair of filters returned by
wt = modwt(x,"db2");
is equivalent to
[~,~,Lo,Hi] = wfilters("db2"); wt =
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 equal to
x is a vector, or
= size(x,1) if
x is a matrix. If
lev defaults to
alignflag — Time align coefficients logical
0 (default) |
Time align coefficients logical which determines whether the MODWT
circularly shifts the wavelet coefficients at all levels (scales) and the
scaling coefficients to correct for the delay of the scaling and wavelet
filters, specified as a numeric or logical
false). Coefficients are shifted using the "center
of energy" method of Hess-Nielsen and Wickerhauser .
Shifting the coefficients is useful if you want to time align features in
the signal with the wavelet coefficients.
If you want to reconstruct the signal with the
imodwt function, or obtain a
multiresolution analysis using the
modwtmra function, do not
shift the coefficients. In those cases, the time alignment is performed in
obtaining the inverse or multiresolution analysis.
w — MODWT transform
matrix | 3-D array
MODWT transform of
the wavelet coefficients and final-level scaling coefficients of
x is a vector,
w is a
lev+1-by-N matrix. If
x is a matrix,
w is a
array, where NC is the number of columns in
x. N is equal to the input
signal length unless you specify
handling, in which case N is twice the length of the
input signal. The kth row of the array,
w, contains the wavelet coefficients for scale
2k (wavelet scale
2(k-1)). The final,
lev+1)th, row contains the scaling coefficients
for scale 2
The standard algorithm for the MODWT implements the circular convolution directly in the time domain. This implementation of the MODWT performs the circular convolution in the Fourier domain. The wavelet and scaling filter coefficients at level j are computed by taking the inverse discrete Fourier transform (DFT) of a product of DFTs. The DFTs in the product are the signal’s DFT and the DFT of the jth level wavelet or scaling filter.
Let Hk and Gk denote the length N DFTs of the MODWT wavelet and scaling filters, respectively. Let j denote the level and N denote the sample size.
The jth level wavelet filter is defined by
The jth level scaling filter is
 Percival, Donald B., and Andrew T. Walden. Wavelet Methods for Time Series Analysis. Cambridge Series in Statistical and Probabilistic Mathematics. Cambridge ; New York: Cambridge University Press, 2000.
 Percival, Donald B., and Harold O. Mofjeld. “Analysis of Subtidal Coastal Sea Level Fluctuations Using Wavelets.” Journal of the American Statistical Association 92, no. 439 (September 1997): 868–80. https://doi.org/10.1080/01621459.1997.10474042.
 Mesa, Hector. “Adapted Wavelets for Pattern Detection.” In Progress in Pattern Recognition, Image Analysis and Applications, edited by Alberto Sanfeliu and Manuel Lazo Cortés, 3773:933–44. Berlin, Heidelberg: Springer Berlin Heidelberg, 2005. https://doi.org/10.1007/11578079_96.
 Hess-Nielsen, N., and M.V. Wickerhauser. “Wavelets and Time-Frequency Analysis.” Proceedings of the IEEE 84, no. 4 (April 1996): 523–40. https://doi.org/10.1109/5.488698.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
wnamemust be constant.
GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
Usage notes and limitations:
wnamemust be constant.
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Introduced in R2015b