Multisignal 1-D wavelet reconstruction
This example shows how to reconstruct a multisignal and a user-specified signal within the multisignal.
Load the 23 channel EEG data
Espiga3 . The channels are arranged column-wise. The data is sampled at 200 Hz.
load Espiga3 size(Espiga3)
ans = 1×2 995 23
Perform a decomposition at level 2 using the
dec = mdwtdec('c',Espiga3,2,'db2');
Reconstruct the original matrix of signals using the decomposition structure
XR = mdwtrec(dec);
Compute the reconstruction error.
errREC = max(abs(Espiga3(:)-XR(:)))
errREC = 3.5431e-10
Reconstruct the original signal at index 17, the corresponding approximation at level 2, and details at levels 1 and 2.
idx = 17; Y = mdwtrec(dec,idx); A2 = mdwtrec(dec,'a',2,idx); D2 = mdwtrec(dec,'d',2,idx); D1 = mdwtrec(dec,'d',1,idx);
Compute the reconstruction error for signal 17.
errREC = max(abs(Y-A2-D2-D1))
errREC = 4.9542e-18
dec — Wavelet decomposition
Wavelet decomposition of a multisignal, specified as a structure with the following fields:
dirDec— Direction indicator:
level— Level of wavelet decomposition
wname— Wavelet name
dwtFilters— Structure with four fields:
dwtEXTM— DWT extension mode
dwtShift— DWT shift parameter (0 or 1)
dataSize— Size of
ca— Approximation coefficients at level
cd— Cell array of detail coefficients, from level 1 to level
The format of
dec matches the output of
idxsig — Indices
positive integer-valued vector
Indices of signals to reconstruct, specified as a positive integer-valued vector.
Example: If S is a matrix of 100 signals and
98]) reconstructs the signals whose row indices are 1, 20, and
lev — Level
Level of coefficients to extract or reconstruct, specified as a nonnegative integer.
levmust be an integer in the interval [0,
levdec = dec.level.
levmust be an integer in the interval [1,
levdec = dec.level.
type — Output type
Output type, specified as one of the following:
'cd'– detail coefficients of level
'd'– detail coefficients of level
'ca'– approximation coefficients of level
'a'– approximation coefficients of level
mode — Order of concatenation
'descend' (default) |
Order of concatenation, specified as
mode = 'descend', the coefficients
are concatenated from level
levdec to level 1, where
= dec.level. If
mode = 'ascend', the coefficients are
concatenated from level 1 to level
levdec. The concatenation is made
dec.dirDEC = 'r' or column-wise if
x — Reconstructed signals
Reconstructed signals, returned as a real-valued matrix.
y — Decomposition coefficients
Decomposition coefficients, returned as a real-valued matrix, depending on
'cd'– extracted detail coefficients
'ca'– extracted approximation coefficients
'd'– reconstructed detail coefficients
'a'– reconstructed approximation coefficients
a — Reconstructed approximation coefficients
Reconstructed approximation coefficients, returned as a real-valued matrix.
d — Reconstructed detail coefficients
Reconstructed detail coefficients, returned as a real-valued matrix.
ca — Extracted approximation coefficients
Extracted approximation coefficients, returned as a real-valued matrix.
cd — Extracted detail coefficients
Extracted detail coefficients, returned as a real-valued matrix.
cfs — Extracted approximation and detail coefficients
Extracted approximation and detail coefficients, returned as a real-valued matrix.
 Daubechies, I. Ten Lectures on Wavelets. CBMS-NSF Regional Conference Series in Applied Mathematics. Philadelphia, PA: Society for Industrial and Applied Mathematics, 1992.
 Mallat, S. G. “A Theory for Multiresolution Signal Decomposition: The Wavelet Representation.” IEEE Transactions on Pattern Analysis and Machine Intelligence. Vol. 11, Issue 7, July 1989, pp. 674–693.
 Meyer, Y. Wavelets and Operators. Translated by D. H. Salinger. Cambridge, UK: Cambridge University Press, 1995.
 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.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
typemust be constant.
Introduced in R2007a