我要加入 登录
声振论坛 返回首页

lyg112002的个人空间 http://home.vibunion.com/?113863 [收藏] [复制] [分享] [RSS]

日志

信号分析与处理

已有 697 次阅读2009-3-22 22:46 |

clear all
close all;
load('xindian1.txt');
y=xindian1(:,1);
n=(1:size(y))';

figure(1);
hold on
y=y(1:1:1000);
n=n(1:1:1000);
plot(y,n);
 
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('阈值');
 
 
 
 
 

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 我要加入

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-4-28 21:13 , Processed in 0.036477 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部