资源描述:
《小波变换程序.docx》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、小波滤波器构造和消噪程序(2个)1.重构%mallet_wavelet.m%此函数用于研究Mallet算法及滤波器设计%此函数仅用于消噪a=pi/8;%角度赋初值b=pi/8;%低通重构FIR滤波器h0(n)冲激响应赋值h0=cos(a)*cos(b);h1=sin(a)*cos(b);h2=-sin(a)*sin(b);h3=cos(a)*sin(b);low_construct=[h0,h1,h2,h3];L_fre=4;%滤波器长度low_decompose=low_construct(end:-1:1);%确
2、定h0(-n),低通分解滤波器fori_high=1:L_fre;%确定h1(n)=(-1)^n,高通重建滤波器if(mod(i_high,2)==0);coefficient=-1;elsecoefficient=1;endhigh_construct(1,i_high)=low_decompose(1,i_high)*coefficient;endhigh_decompose=high_construct(end:-1:1);%高通分解滤波器h1(-n)L_signal=100;%信号长度n=1:L_signal
3、;%信号赋值f=10;t=0.001;y=10*cos(2*pi*50*n*t).*exp(-20*n*t);figure(1);plot(y);title('原信号');check1=sum(high_decompose);%h0(n)性质校验check2=sum(low_decompose);check3=norm(high_decompose);check4=norm(low_decompose);l_fre=conv(y,low_decompose);%卷积l_fre_down=dyaddown(l_fre)
4、;%抽取,得低频细节h_fre=conv(y,high_decompose);h_fre_down=dyaddown(h_fre);%信号高频细节figure(2);subplot(2,1,1)plot(l_fre_down);title('小波分解的低频系数');subplot(2,1,2);plot(h_fre_down);title('小波分解的高频系数');l_fre_pull=dyadup(l_fre_down);%0差值h_fre_pull=dyadup(h_fre_down);l_fre_denoise
5、=conv(low_construct,l_fre_pull);h_fre_denoise=conv(high_construct,h_fre_pull);l_fre_keep=wkeep(l_fre_denoise,L_signal);%取结果的中心部分,消除卷积影响h_fre_keep=wkeep(h_fre_denoise,L_signal);sig_denoise=l_fre_keep+h_fre_keep;%信号重构compare=sig_denoise-y;%与原信号比较figure(3);subplot
6、(3,1,1)plot(y);ylabel('y');%原信号subplot(3,1,2);plot(sig_denoise);ylabel('sig_denoise');%重构信号subplot(3,1,3);plot(compare);ylabel('compare');%原信号与消噪后信号的比较2.消噪%mallet_wavelet.m%此函数用于研究Mallet算法及滤波器设计%此函数用于消噪处理%角度赋值%此处赋值使滤波器系数恰为db9%分解的高频系数采用db9较好,即它的消失矩较大%分解的有用信号小波高
7、频系数基本趋于零%对于噪声信号高频分解系数很大,便于阈值消噪处理[l,h]=wfilters('db10','d');low_construct=l;L_fre=20;%滤波器长度low_decompose=low_construct(end:-1:1);%确定h0(-n),低通分解滤波器fori_high=1:L_fre;%确定h1(n)=(-1)^n,高通重建滤波器if(mod(i_high,2)==0);coefficient=-1;elsecoefficient=1;endhigh_construct(1,i
8、_high)=low_decompose(1,i_high)*coefficient;endhigh_decompose=high_construct(end:-1:1);%高通分解滤波器h1(-n)L_signal=100;%信号长度n=1:L_signal;%原始信号赋值f=10;t=0.001;y=10*cos(2*pi*50*n*t).