www.pudn.com > 1.rar > general2nddecm.m, change:2008-03-11,size:2141b


function [c,d]=general2nddecm(data) 
% the program is edited for 2nd wavlet decompositon 
% 
% data--- be processed data,even length 
% predict_coif---predict coefficients,even length 
% update_coif---update,even length 
% 
% c---coarse component 
% d---detail component 
 
% % P U number: 18 
% predict_coef=[0.0000 -0.0000 0.0003 -0.0016 0.0067 -0.0225 0.0630 -0.1651 0.6192 0.6192 -0.1651 0.0630 -0.0225 0.0067 -0.0016 0.0003 -0.0000 0.0000]; 
% update_coef=[0.0000 -0.0000 0.0001 -0.0008 0.0034 -0.0113 0.0315 -0.0826 0.3096 0.3096 -0.0826 0.0315 -0.0113 0.0034 -0.0008 0.0001 -0.0000 0.0000]; 
 
% P U number: 4 
predict_coef=[-0.0625 0.5625 0.5625 -0.0625]; 
update_coef=[-0.0313 0.2813 0.2813 -0.0313]; 
 
% coeff length 
len_data=length(data); 
len=len_data/2; 
Np=length(predict_coef); 
Nu=length(update_coef); 
 
% splitting step 
for i=1:len 
    x_even(i)=data(2*i-1); 
    x_odd(i)=data(2*i); 
end 
 
%boundery processing 
 
%left 
if Np>2 
    for i=1:(Np/2-1) 
        x_even_left(Np/2-i)=x_even(i+1); 
    end 
% else 
%    x_even_left(1)=0; 
end 
 
%right 
for i=1:(Np/2) 
    x_even_right(i)=x_even(len-i+1); 
end 
 
%expended x_even 
 
x_even_exp=[x_even_left,x_even,x_even_right]; 
x_odd=[x_even_left,x_odd,x_even_right]; 
 
% predicting step 
 
for k=(length(x_even_left)+1):(length(x_even_exp)-length(x_even_right)) 
    predict_sum=0; 
    for i=1:Np 
        predict_sum=predict_sum+predict_coef(i)*x_even_exp(k+i-Np/2); 
    end 
    d(k)=x_odd(k)-predict_sum; 
end 
 
%detail 
 
d=d((length(x_even_left)+1):(length(x_even_exp)-length(x_even_right))); 
d1=d; 
 
%update step 
 
% boundery processing 
 
%left 
 
for i=1:Nu/2 
    d_left(i)=d(Nu/2-i+1); 
end 
 
%right 
if Nu>2 
    for i=1:(Nu/2-1) 
        d_right(i)=d(len-i+1); 
    end 
else 
    d_right(1)=0; 
end 
 
%expended d 
 
d=[d_left,d,d_right]; 
x_even_x=[d_left,x_even,d_right]; 
 
%updating 
for k=(length(d_left)+1):length(d)-length(d_right) 
    update_sum=0; 
    for i=1:Nu 
        update_sum=update_sum+update_coef(i)*d(k-Nu/2+i-1); 
    end 
    c1(k)=x_even_x(k)+update_sum; 
end 
 
c=c1((length(d_left)+1):length(d)-length(d_right)); 
d=d1;