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


function [data]=general2ndre(c,d) 
% 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]; 
 
% coeff length 
len=length(c); 
Np=length(predict_coef); 
Nu=length(update_coef); 
 
%undo updating 
d1=d; 
%boundery 
%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 
 
c1=[d_left,c,d_right]; 
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 
    x_even_x(k)=c1(k)-update_sum; 
end 
 
x_even=x_even_x((length(d_left)+1):length(d)-length(d_right)); 
 
% undo predicting 
 
%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]; 
d=[x_even_left,d1,x_even_right]; 
 
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 
    x_odd1(k)=d(k)+predict_sum; 
end 
 
x_odd=x_odd1((length(x_even_left)+1):(length(x_even_exp)-length(x_even_right))); 
 
% splitting step 
for i=1:len 
    data(2*i-1)=x_even(i); 
    data(2*i)=x_odd(i); 
end