|
毕设教师要求做一个根据小波改换信号去噪的程序,可是一向呈现过错运用 horzcat 串联的矩阵的维度不一致。用的maltab2014a,请大神费眼
clear all;clc
load('C:\Users\Desktop\昆虫电位\w2016.mat');
s=w2016(1:800);%取采样信号的前1-800个采样点
figure(1);
plot(s);
ylabel('s');
title('原始信号');
[c,l]=wavedec(s,6,'coif4'); %小波基为coif4,分化层数为6层
a6=appcoef(c,l,'coif4',6); %提取小波分化的低频系数
d6=detcoef(c,l,6);%提取第六层高频系数
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);%提取第一层高频系数
thr2=thselect(d2,'rigrsure')%获取阈值,运用Stein的无偏危险估量原理
thr3=thselect(d3,'rigrsure')
thr4=thselect(d4,'rigrsure')
thr5=thselect(d5,'rigrsure')
thr6=thselect(d6,'rigrsure')
sd1=zeros(1,length(d1)); %d1,a6层置零, d2-d6层用软阈值函数处理
sd6=zeros(1,length(a6));
sd2=wthresh(d2,'s',thr2); % d2-d6层用软阈值函数处理
sd3=wthresh(d3,'s',thr3);
sd4=wthresh(d4,'s',thr4);
sd5=wthresh(d5,'s',thr5);
sd5=wthresh(d6,'s',thr6);
c2=[a6,sd1,sd2,sd3,sd4,sd5,sd6];
s0=waverec(c2,l,'coif4'); %小波重构
figure(2);
plot(s0);
ylabel('s');
title('除噪后的信号');
|
|