⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wavlet_denoise.m

📁 此函数用于研究Mallet算法及滤波器设计 此函数用于消噪处理 分解的高频系数采用db9较好,即它的消失矩较大 分解的有用信号小波高频系数基本趋于零 对于噪声信号高频分解系数很大
💻 M
字号:
%  mallet_wavelet.m
%  此函数用于研究Mallet算法及滤波器设计
%  此函数用于消噪处理
%  角度赋值
%  此处赋值使滤波器系数恰为db9
%  分解的高频系数采用db9较好,即它的消失矩较大
%  分解的有用信号小波高频系数基本趋于零
%  对于噪声信号高频分解系数很大,便于阈值消噪处理
clear;
clc;

[l,h]=wfilters('db10','d');       %‘d’表示分解decompose
low_construct=l;
L_fre=20;                                 %滤波器长度
low_decompose=low_construct(end:-1:1);    %确定h0(-n),低通分解滤波器
for i_high=1:L_fre;                       %确定h1(n)=(-1)^n,高通重建滤波器
    if(mod(i_high,2)==0);
        coefficient=-1;
    else
        coefficient=1;
    end
    high_construct(1,i_high)=low_decompose(1,i_high)*coefficient;
end
high_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).*exp(-30*n*t);

zero1=zeros(1,50);    %信号加噪声信号产生
zero2=zeros(1,30);
noise=[zero1,1*(randn(1,20)-0.5),zero2];
y_noise=y+noise;

figure(1);
subplot(2,1,1);plot(y);title('原信号');
subplot(2,1,2);plot(y_noise);title('受噪声污染的信号');

check1=sum(high_decompose);   %h0(n),性质校验
check2=sum(low_decompose);
check3=norm(high_decompose);
check4=norm(low_decompose);

l_fre=conv(y_noise,low_decompose);        %卷积
l_fre_down=dyaddown(l_fre);         %抽取,得低频细节

h_fre=conv(y_noise,high_decompose);
h_fre_down=dyaddown(h_fre);       %信号高频细节

figure(2);
subplot(2,1,1);plot(l_fre_down);title('小波分解的低频系数l_fre_down');
subplot(2,1,2);plot(h_fre_down);title('小波分解的高频系数h_fre_down');

% 消噪处理
 for i_decrease=21:44;
   if abs(h_fre_down(1,i_decrease))>=0.000001
       h_fre_down(1,i_decrease)=(10^-7);
   end
 end
l_fre_pull=dyadup(l_fre_down);     %0差值
h_fre_pull=dyadup(h_fre_down);

l_fre_denoise=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;          %消噪后信号重构

%平滑处理
for j=1:2
  for i=50:70;
    sig_denoise(i)=(sig_denoise(i-2)+sig_denoise(i+2))/2;
  end;
end;
compare=sig_denoise-y;                      %与原信号比较

figure(3);
subplot(3,1,1);plot(y_noise);ylabel('y');            %原信号
subplot(3,1,2);plot(sig_denoise);ylabel('sig\_denoise'); %消噪后信号
subplot(3,1,3);plot(compare);ylabel('compare');      %原信号与消噪后信号的比较 


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -