⼩波阈值去噪MATLAB代码,(转载)
例1:
load leleccum;
index = 1:1024;
x = leleccum(index);
%产⽣噪声信号
init = 2055615866;
randn('seed',init);
nx = x + 18*randn(size(x));
%获取消噪的阈值
[thr,sorh,keepapp] = ddencmp('den','wv',nx);
%对信号进⾏消噪
xd = wdencmp('gbl',nx,'db4',2,thr,sorh,keepapp);
subplot(221);
plot(x);
title('原始信号');
subplot(222);
plot(nx);
title('含噪信号');
subplot(223);
plot(xd);
title('消噪后的信号');
例2:
本例中,⾸先使⽤函数wnoisest获取噪声⽅差,然后使⽤函数wbmpen获取⼩波去噪阈值,最后使⽤wdencmp实现信号消噪。load leleccum;
indx = 1:1024;
x = leleccum(indx);
%产⽣含噪信号
init = 2055615886;
randn('seed',init);
nx = x + 18*randn(size(x));
%使⽤⼩波函数'db6'对信号进⾏3层分解
[c,l] = wavedec(nx,3,'db6');
%估计尺度1的噪声标准差
sigma = wnoisest(c,l,1);
alpha = 2;
%获取消噪过程中的阈值
thr = wbmpen(c,l,sigma,alpha);
keepapp = 1;
%对信号进⾏消噪
xd = wdencmp('gbl',c,l,'db6',3,thr,'s',keepapp);
subplot(221);
plot(x);
title('原始信号');
subplot(222);
plot(nx);
title('含噪信号');
subplot(223);
plot(xd);
title('消噪后的信号');
例3:
本例中,对⼩波分解系数使⽤函数wthcoef进⾏阈值处理,然后利⽤阈值处理后的⼩波系数进⾏重构达到去噪⽬的。load leleccum;
indx = 1:1024;
x = leleccum(indx);
%产⽣含噪信号
init = 2055615866;
randn('seed',init);
nx = x + 18*randn(size(x));
%使⽤⼩波函数'db5'对信号进⾏3层分解
[c,l] = wavedec(nx,3,'db5');
%设置尺度向量
n = [1,2,3];
%设置阈值向量
p = [100,90,80];
%对⾼频系数进⾏阈值处理
nc = wthcoef('d',c,l,n,p);
%对修正后的⼩波分解结构进⾏重构
rx = waverec(nc,l,'db5');
subplot(221);
plot(x);
title('原始信号');
subplot(222);
plot(nx);
title('含噪信号');
subplot(223);
plot(rx);
title('消噪后的信号');
例4:
本例中,使⽤⼀维信号的⾃动消噪函数wden对信号进⾏消噪。load leleccum;
indx = 1:1024;
x = leleccum(indx);
%产⽣含噪信号
init = 2055615866;
randn('seed',init);
nx = x + 18*randn(size(x));
%将信号nx使⽤⼩波函数'sym5'分解到第5层
%使⽤mimimaxi阈值选择系数进⾏处理,消除噪声信号
lev = 5;
xd = wden(nx,'minimaxi','s','mln',lev,'sym5');
subplot(221);
plot(x);
title('原始信号');
用subplot函数
subplot(222);
plot(nx);
title('含噪信号');
subplot(223);
plot(xd);
title('消噪后的信号');
x=[-1.58 0.42 0.46 0.78 -0.49 0.59 -1.3 -1.42 -0.16 -1.47 -1.350.36 -0.44 -0.14 1 -0.5 -0.2 -0.06 -0.6 0.42 -1.52 0.51 0.76 -1.50.16 -1.29 -0.65 -1.48 0.6 -1.65 -0.55];
lev=5;
wname='db3';
[c,l]=wavedec(x,lev,wname);
sigma=wnoisest(c,l,1);
alpha=2;
thr1=wbmpen(c,l,sigma,alpha)
[thr2,nkeep]=wdcbm(c,l,alpha)
xd1=wdencmp('gbl',c,l,wname,lev,thr1,'s',1);
[xd2,cxd,lxd,perf0,perfl2]=wdencmp('lvd',c,l,wname,lev,thr2,'h');
[thr,sorh,keepapp]=ddencmp('den','wv',x)
xd3=wdencmp('gbl',c,l,wname,lev,thr,'s',1);
subplot(411);plot(x);title('原始信号','fontsize',12);
subplot(412);plot(xd1);title('使⽤penalty阈值降噪后信号','fontsize',12);
subplot(413);plot(xd2);title('使⽤Birge-Massart阈值降噪后信号','fontsize',12);
subplot(414);plot(xd3);title('使⽤缺省阈值降噪后信号','fontsize',12);
其他相关帖⼦:

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。