www.gusucode.com > wavelet 源码程序 matlab案例代码 > wavelet/FirstLevelDetailCoefficientsApproximationComplexDualTreeExample.m

    %% First-Level Detail Coefficients Approximation — Complex Dual-Tree  
% Obtain the complex dual-tree wavelet transform of a signal with two 
% discontinuities. Use the first-level detail coefficients to localize the 
% discontinuities.   

%% 
% Create a signal consisting of a 2-Hz sine wave with a duration of 1 second.
% The sine wave has discontinuities at 0.3 and 0.72 seconds. 
N = 1024;
t = linspace(0,1,1024);
x = 4*sin(4*pi*t);
x = x - sign(t - .3) - sign(.72 - t);
plot(t,x); xlabel('t'); ylabel('x');
title('Original Signal');  

%% 
% Obtain the dual-tree wavelet transform of the signal, reconstruct an 
% approximation based on the level-one detail coefficients, and plot the 
% result. 
wt = dddtree('cplxdt',x,1,'FSfarras','qshift06');
wt.cfs{2} = zeros(1,512,2);
xrec = idddtree(wt);
plot(t,xrec,'linewidth',2)
set(gca,'xtick',[0 0.3 0.72 1]); set(gca,'xgrid','on');