# sparsifying an ECG signal using wavelet

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.

• Welcome to SE.DSP. Why do you want to sparsify an ECG? How would you measure that? Why do you want to use a DWT? Those plot are probably produce with Matlab, concatenating coefficients for low to high pass. – Laurent Duval Aug 20 '17 at 19:42
• thank you very much. I'm working on a compressive sensing project, and need to find a sparsifying base for the ECG signal. i used the DCT but the result wasn't so satisfactory. In fact there is some Dictionary learning method but need some straightforward methods for this problem. – Salman Aug 20 '17 at 20:52
• "I need to" <-- is not a reason. Can you give us a technological or mathematical motivation for the sparsification? What you need to do depends on why you do it. – Marcus Müller Aug 20 '17 at 21:09
• dear Marcus Müller, tnx for your comment. As I told, i'm working on a compressive sensing project that aim to compress the ECG signals. based on many papers the ECG signals is sparse in some basis like DCT and DWT. I want to know how it is possible to use Wavelet to sparsifying the ECG signals. This is all i want and said. tnx again – Salman Aug 20 '17 at 21:33

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