I have an ECG signal, and want to sparsify it using wavelet (DWT) in Matlab. In some paper they use Daubechies wavelet (DB4) with 8-tap filters. but i don't know how to extract the wavelet coefficients and plot a figure like this:
tnx.
I have an ECG signal, and want to sparsify it using wavelet (DWT) in Matlab. In some paper they use Daubechies wavelet (DB4) with 8-tap filters. but i don't know how to extract the wavelet coefficients and plot a figure like this:
tnx.
As illustrated by the simplified figure and the Matlab code below, such a graph can be obtained with a standard discrete wavelet decomposition, possibly with a periodic extension to preserve the size, over 3 to 5 levels of decomposition. Wavelet coefficients are simply concatenated in the standard low-frequency /high-frequency fashion, with scaling coefficients first, and followed by the wavelet coefficients.
load ecgData;
data = x(1:256,1);
waveletName = 'db4';
waveletLevel = 4;
dwtmode('ppd');
[C,L] = wavedec(data,waveletLevel,waveletName);
subplot(2,1,1); plot(data);axis tight
subplot(2,1,2); stem(C);axis tight