|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
下面是我自己的加噪(加的是高斯白噪声)和小波去噪程序,去噪效果不理想,大家帮我看看是不是我小波去噪的参数选择的不对,谢谢诸位了
clc;
close all;
clear all;
%源信号
p1=30;p2=50; %frequencies of s1
p3=60; %frequencies of s2
SigLen=512; %length of the sources
points=512; %number of represented points
m=2;n=2; %m为源数,n为观测信号数
s1=sin([1:SigLen]*p1*2*pi/SigLen)+sin([1:SigLen]*p2*2*pi/SigLen); %源信号s1
s2=sin([1:SigLen]*p3*2*pi/SigLen); %源信号s2
s=[s1;s2]; %源信号矩阵
for i=1:n
s(i,:)=s(i,:)-mean(s(i,:)); %中心化(去均值)
s(i,:)=s(i,:)/std(s(i,:)); %normalization of the source signals
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%观测信号
A11=1;A22=1;A12=-0.72222;A21=-0.59447;
A=[A11 A12;A21 A22]; %混合矩阵A
X=A*s; %观测信号X
subplot(3,2,1),plot(X(1,:),'MarkerEdgeColor','k','MarkerFaceColor','k'); %观测信号x1的图形
title('观测信号 1');
set(gca,'xlim',[0 points]),set(gca,'xtick',[0:points/4:points]);
subplot(3,2,2),plot(X(2,:),'MarkerEdgeColor','k','MarkerFaceColor','k') %观测信号x2的图形
title('观测信号 2');
set(gca,'xlim',[0 points]),set(gca,'xtick',[0:points/4:points]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%noise on signal 1:
snr1=-30; %信噪比为-30db
X_noised(1,:)=zeros(1,length(X(1,:)));
X_noised(1,:)=awgn(X(1,:),snr1);
subplot(3,2,3),plot(X_noised(1,:),'MarkerEdgeColor','k','MarkerFaceColor','k');
title('加噪观测信号 1');
set(gca,'xlim',[0 points]),set(gca,'xtick',[0:points/4:points]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%noise on signal 2:
snr2=-20; %信噪比为-20db
X_noised(2,:)=zeros(1,length(X(2,:)));
X_noised(2,:)=awgn(X(2,:),snr2);
subplot(3,2,4),plot(X_noised(2,:),'MarkerEdgeColor','k','MarkerFaceColor','k');
title('加噪观测信号 2');
set(gca,'xlim',[0 points]),set(gca,'xtick',[0:points/4:points]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%对观测信号进行小波阈值消噪
X_denoised=zeros(n,SigLen);
TPTR_before='heursure'; %threshold selection rule
thresholding_before='s'; %阈值选择
Lev_before=2; %小波的分解层数
Wname='sym6'; %wavelet basis
%对第一个含噪观测信号X_noised(1,:)进行小波阈值消噪
[xd,cxd,lxd]=wden(X_noised(1,:),TPTR_before,thresholding_before,'sln',Lev_before,Wname);
X_denoised(1,:)=xd;
subplot(3,2,5),plot(X_denoised(1,:),'MarkerEdgeColor','k','MarkerFaceColor','k'); %估计消噪后观测信号X_denoised1的图形
title('小波消噪后观测信号 1');
set(gca,'xlim',[0 points]),set(gca,'xtick',[0:points/4:points]);
%对第二个含噪观测信号X_noised(2,:)进行小波阈值消噪
[xd,cxd,lxd]=wden(X_noised(2,:),TPTR_before,thresholding_before,'sln',Lev_before,Wname);
X_denoised(2,:)=xd;
subplot(3,2,6),plot(X_denoised(2,:),'MarkerEdgeColor','k','MarkerFaceColor','k'); %估计消噪后观测信号X_denoised2的图形
title('小波消噪后观测信号 2');
set(gca,'xlim',[0 points]),set(gca,'xtick',[0:points/4:points]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|