This example shows how to compress a 1-D signal using wavelet packets.
Load a signal. Use ddencmp to determine compression values for that signal.
load sumlichr
x = sumlichr;
[thr,sorh,keepapp,crit] = ddencmp('cmp','wp',x)
thr = 0.5193
sorh =
'h'
keepapp = 1
crit =
'threshold'
Compress the signal using global thresholding with threshold best basis. Use the order 4 Daubechies least asymmetric wavelet and do a three-level wavelet packet decomposition.
[xc,wpt,perf0,perfl2] = wpdencmp(x,sorh,3,'sym4',crit,thr,keepapp);
Compare the original signal with the compressed version.
subplot(2,1,1)
plot(x)
title('Original Signal')
axis tight
subplot(2,1,2)
plot(xc)
xlabel(['L^2 rec.: ',num2str(perfl2),'% zero cfs.: ',num2str(perf0),'%'])
title('Compressed Signal Using Wavelet Packets')
axis tight
Compress the signal again, but this do a three-level wavelet decomposition. Keep all the other parameters the same.
[thr,sorh,keepapp] = ddencmp('cmp','wv',x);
[xcwv,~,~,perf0wv,perfl2wv] = wdencmp('gbl',x,'sym4',3,thr,sorh,keepapp);
figure
subplot(2,1,1)
plot(x)
title('Original Signal')
axis tight
subplot(2,1,2)
plot(xc)
xlabel(['L^2 rec.: ',num2str(perfl2wv),'% zero cfs.: ',num2str(perf0wv),'%'])
title('Compressed Signal Using Wavelets')
axis tight
A larger fraction of coefficients are set equal to 0 when compressing using a wavelet packet decomposition.