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

📄 xindianzyj.m

📁 包含心电数据的差分、小波、巴特沃思滤波器等滤波方法。
💻 M
字号:
clear all
close all;
load('300.txt');
y=X300(:,2);
n=(1:size(y))';


figure(1);
hold on
y=y(1:1000);
n=n(1:1000);
plot(n,y);

 
figure(2);
wn=0.3;
N=3;
[b,a]=butter(N,wn,'low');
m=filter(b,a,y);
plot(n,m);
title('巴特沃思滤波');

[c,l]=wavedec(m,2,'rbio6.8');
a4=wrcoef('a',c,l,'rbio6.8',2);
figure(6);
plot(n,a4);
title('小波滤波');

for i=1:(length(a4)-1)
      c1(i)=a4(i+1)-a4(i);
  end
  c2=abs(c1);
  figure(8);
  size(c2)
  n=n(1:(length(n)-1));
plot(n,c2);
 title('差分');

 for j=2:(length(c2)-1)
   c3(j)=[c2(j-1)+c2(j)+c2(j+1)]/3;
end
 figure(9);
 size(c3)
 length(n)
  n=n(1:(length(n)-1));
plot(n,c3);
 title('三点平滑');
 
 
  for i=1:(length(c3)-1)
      c4(i)=c3(i+1)-c3(i);
  end
  c5=abs(c4);
  figure(10);
  size(c5)
 length(n)
   n=n(1:(length(n)-1));
plot(n,c5);
 title('差分');

 for j=2:(length(c5)-1)
   c6(j)=[c5(j-1)+c5(j)+c5(j+1)]/3;
end
 figure(11);
   n=n(1:(length(n)-1));
plot(n,c6);
 title('三点平滑');
 
 size(c5)
 size(c6)
 
 for j=1:(length(c6))
   c7(j)=c5(j)+c6(j);
end
for j=2:(length(c7)-1)
   c8(j)=[c7(j-1)+c7(j)+c7(j+1)]/3;
end
 figure(12);
   n=n(1:(length(n)-1));
plot(n,c8);
 title('和三点平滑');
 
 p=c8;
 d1=0.22*p;
 d2=0.15*p;
 
 for i=1:(length(p))
 if p(i)>d1
     p(i)=1;
 else 
     p(i)=0;
 end
end   

for i=1:(length(p))
 if p(i)>d2
     p(i)=1;
 else 
     p(i)=0;
 end
end
  figure(13);
plot(n,p);
axis([0,1000,0, 1.05]);
 title('阈值'); 
 
 s=1;
 for i=1:(length(p)-23)
   if((p(i+1)-p(i))>0) 
       s=s+1;
       fh(s)=1;
       fi(s)=i+1;
       Flag=0;
   else
       s=s+1;
       fh(s)=-1;
       fi(s)=i+1; 
       Flag=1;
   end 
   if  s>2
       if (fi(s)-fi(s-1))<23 
           p(fi(s-1):fi(s))=Flag;
       end
   end
end
  figure(14);
plot(n,p);
axis([0,1000,0, 1.05]);
 title('阈值');
 

 
 
 
 

⌨️ 快捷键说明

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