该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
%SSNF算法基于小波变换尺度间相关性的去噪
clear all
%分解次数scale =6;
%噪声方差sigmasigma1=0.5;
%是否使用我们提出的改进方案1使用,0不使用,默认使用use=0;
%均值滤波的窗长为2×windows+1windows=3;
%迭代去噪次数iter=1;
%点数N=1024;
%系数设定
使用二进制样条小波%分析滤波器 -1 0 1 2 h_wave = [0.125 0.375 0.375 0.125]*sqrt(2);
%h_wave=[0.375 0.25 0.0625 0 0]*sqrt(2);
%综合滤波器
%h=[0.375 0.25 0.0625 0 0]*sqrt(2);
% -1 0 1 2h = [0.125 0.375 0.375 0.125]*sqrt(2);
% h_wave_bias = 0;
% h_bias = 0;
h_wave_bias = 1;h_bias = 1;
%分析滤波器% g_wave=[0 0.59261 0.10872 0.01643 0.00008]*sqrt(2);
% -2 -1 0 1 2 3g = [0.015625 0.109375 0.34375 -0.34375 -0.109375 -0.015625]*sqrt(2);
%综合滤波器
% 0 1
% g=[0 0.59261 0.10872 0.01643 0.00008]*sqrt(2);g_wave = [1.0 -1.0]*sqrt(2);g_wave_bias = 0;g_bias = 2;
% g_wave_bias = 0;
% g_bias = 0;
%=============三次正交样条===============
%系数设定 使用二进制样条小波
% h_wave = [0.375 0.25 0.0625 0 0]*sqrt(2);
% % %综合滤波器% h = [0.375 0.25 0.0625 0 0]*sqrt(2);
% % h_wave_bias = 0;% h_bias = 0;
% % %分析滤波器
% g_wave = [0 0.59261 0.10872 0.01643 0.00008]*sqrt(2);
% %综合滤波器
% g=[0 0.59261 0.10872 0.01643 0.00008]*sqrt(2);
% g_wave_bias = 0;
% g_bias = 0;
y = [];step = [];
%产生信号sigma2=0;for t = 0 : 0.005 :5.115 step = [step t];
if t<1.0
y = [y 2-random('Normal',0,sigma2)];
elseif t<1.6 y = [y 5+0.5-random('Normal',0,sigma2)];
elseif t<2.0 y = [y 9+0.5-random('Normal',0,sigma2)];
elseif t<3 y= [y 5+0.5-random('Normal',0,sigma2)];
elseif t<3.5 y=[y 6.5+0.5-random('Normal',0,sigma2)];
elseif t<4 y=[y 5+0.5-random('Normal',0,sigma2)];
else y=[y 2-random('Normal',0,sigma2)];
endendfigure(7)y_orginal=y;plot(y_orginal);
clear y step;y=[];step=[];
for t = 0 : 0.005 :5.115 step = [step t];
if t<1.0 y = [y 2-random('Normal',0,sigma1)];
elseif t<1.6 y = [y 5+0.5-random('Normal',0,sigma1)];
elseif t<2.0 y = [y 9+0.5-random('Normal',0,sigma1)];
elseif t<3 y= [y 5+0.5-random('Normal',0,sigma1)];
elseif t<3.5 y=[y 6.5+0.5-random('Normal',0,sigma1)];
elseif t<4 y=[y 5+0.5-random('Normal',0,sigma1)];
else y=[y 2-random('Normal',0,sigma1)];
endend
%求出信号功率与噪声功率的比值
signal_power=sum(y_orginal.^2)/N;
noise_power=sum((y-y_orginal).^2);
signal_power/noise_powermse=1/N*sum((y-y_orginal).^2);
figure(1)subplot(2,1,1);plot(step,y);
title('原始信号');
% load noisbloc;
% step=1:256;
% y=noisbloc(1:256);
% figure(3)% plot(y);
% figure(1);% plot(step,y);
% %axis([0 5 0 10]);
% title('original signal');
for ll=1:iter;
dout = [];xout = y;dd = [];xx = [];
data=zeros(1,N);data(1)=1;factorout=[];
%信号分解for j = 1 : scale [dd,xx] = swt_a(xout,trous(h_wave,j),trous(g_wave,j),(h_wave_bias * (2 ^ j)),(g_wave_bias * (2 ^ j )),j);
dout = [dout dd];
xout = xx;
[dd,xx] = swt_a(data,trous(h_wave,j),trous(g_wave,j),(h_wave_bias * (2 ^ j)),(g_wave_bias * (2 ^ j )),j);
factorout = [factorout dd];
data = xx;endfigure(4)plot(xout);
sigmajfactor=sum(factorout.^2,2);
figure(2);
subplot(6,1,1);
plot(dout(1,:));
subplot(6,1,2);
plot(dout(2,:));
subplot(6,1,3);
plot(dout(3,:));
% subplot(6,1,4);
plot(dout(4,:));
% subplot(6,1,5);
plot(dout(5,:));
% subplot(6,1,6);
plot(dout(6,:));
% subplot(7,1,7);
plot(dout(7,:));
% subplot(9,1,8);
plot(dout(8,:));
% subplot(9,1,9);
plot(dout(9,:));
w=dout;size(dout)ww=w;