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

📄 powerline_db3_noiseclean.m

📁 matlab用于电力线消噪
💻 M
字号:
clear all;
clc;
load leleccum;
% index=2000:3450;
index=2500:3100;
s=leleccum(index);
% s=leleccum;

figure(1)

% subplot(3,2,1);
plot(s);
title('原始信号');
ylabel('幅值 A');
xlabel('实测数据1')
% axis[2500 3100 -450 450]
% axis([400 N -2 2]);



[c,l]=wavedec(s,3,'db3');
a3=appcoef(c,l,'db3',3);
% d5=detcoef(c,l,5);
% d4=detcoef(c,l,4);
d3=detcoef(c,l,3);
d2=detcoef(c,l,2);
d1=detcoef(c,l,1);
%对信号进行强制性消噪处理并图示结果
% dd5=zeros(1,length(d5));
% dd4=zeros(1,length(d4));
dd3=zeros(1,length(d3));
dd2=zeros(1,length(d2));
dd1=zeros(1,length(d1));

c1=[a3 dd3 dd2 dd1];
s1=waverec(c1,l,'db3');

figure(2)

% subplot(3,2,2);
plot(s1);
title('强制消噪后的信号');
xlabel('去噪后数据');
ylabel('幅值 A');

%%用默认阈值对信号进行消噪声处理 并图示结果 
%用ddencmp函数获得信号的默认阈值
% 
[thr,sorh,keepapp]=ddencmp('den','wv',s);
s2=wdencmp('gbl',c,l,'db1',3,thr,sorh,keepapp);

figure(3)
% subplot(3,2,3);
plot(s2);
title('默认阈值消噪后的信号');
xlabel('去噪后数据');
ylabel('幅值 A');
% 
%用给定的软阈值进行消噪处理
softd1=wthresh(d1,'s',1.465);
softd2=wthresh(d2,'s',1.823);
softd3=wthresh(d3,'s',2.768);
% softd4=wthresh(d4,'s',3.768);
% softd5=wthresh(d5,'s',2.567);
c2=[a3 softd3 softd2 softd1];
s3=waverec(c2,l,'db3');

figure(4)
% subplot(3,2,4);
plot(s3);
title('给定软阈值消噪后的信号');
xlabel('去噪后数据');
ylabel('幅值 A');

[c,l]=wavedec(s,5,'db3');
a5=wrcoef('a',c,l,'db3',5);
a4=wrcoef('a',c,l,'db3',4);
a3=wrcoef('a',c,l,'db3',3);
a2=wrcoef('a',c,l,'db3',2);
a1=wrcoef('a',c,l,'db3',1);

d5=wrcoef('d',c,l,'db3',5);
d4=wrcoef('d',c,l,'db3',4);
d3=wrcoef('d',c,l,'db3',3);
d2=wrcoef('d',c,l,'db3',2);
d1=wrcoef('d',c,l,'db3',1);
%消除奇异点
%%设置1-3层细节信号为零
s0=a5+d5+d4;
%画出重构信号

figure(5)
% subplot(3,2,5);
plot(s0);
xlabel('重构后数据');
ylabel('幅值 A');



⌨️ 快捷键说明

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