声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1639|回复: 1

[HHT] 求助有关EMD程序运行

[复制链接]
发表于 2007-6-7 16:54 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
自己参考几个emd的程序编了一个,但是运行的时候好像是死机了,请帮忙找下原因谢谢!!!
function imf = bzemd(y)
k = y(:)'; % copy of the input signal (as a row vector)
N = length(y);
imf = [];
while (1)
      h1 = k; % at the beginning of the sifting process, h is the signal
      SD = 1; % Standard deviation which will be used to stop the sifting process
   
   while SD > 0.3
        maxmin = [];
        maxmin1 = [];
        maxmin2 = [];
      
%%%找到极值点并用3次样条拟合
%对第1点的处理
j=1;
m=1;
s(1)=y(1);
h(1)=1;
j=j+1;
r(1)=y(1);
q(1)=1;
m=m+1;

for i=2:(length(y)-1);
   if and(y(i-1)<y(i),y(i)>=y(i+1));
      s(j)=y(i);
      h(j)=i;
       maxmin1 = [maxmin,j];
      j=j+1;
   end
   if and(y(i-1)>y(i),y(i)<y(i+1));
      r(m)=y(i);
      q(m)=i;
       maxmin2=[maxmin,m];
      m=m+1;
   end
end
maxmin=[maxmin1,maxmin2];
%对最后一点的处理

s(j)=y(length(y));
h(j)=length(y);
r(m)=y(length(y));
q(m)=length(y);
if size(maxmin,2) < 2 % then it is the residue
         break
      end
w=1:length(y);
c1=spline(h,s,w);
c2=spline(q,r,w);
c=(c1+c2)/2;
prevh = h1; % copy of the previous value of h before modifying it
      h1 = h1 - c; % s

% calculate standard deviation
      eps = 0.0000001; % to avoid zero values
      SD = sum ( ((prevh - h1).^2) ./ (prevh.^2 + eps) );
      
   end
   
   imf = [imf; h1]; % store the extracted IMF in the matrix imf
   % if size(maxmin,2)<2, then h is the residue
   
   % stop criterion of the algo.
   if size(maxmin,2) < 2
      break
   end
   
   k = k - h1; % substract the extracted IMF from the signal
   
end

%subplot(5,1,1)
figure(1)
hold on
plot(y)

%subplot(5,1,2)
plot(c1,'r')

%subplot(5,1,3)
plot(c2,'r')


%subplot(5,1,4)


plot(c,'k')

%subplot(5,1,5)
figure(2)
plot(t)


%save f:

[ 本帖最后由 xinyuxf 于 2007-7-25 15:13 编辑 ]
回复
分享到:

使用道具 举报

发表于 2007-6-7 17:39 | 显示全部楼层

回复 #2 xiaojin831108 的帖子

求极值点是不是有问题,可以参考一下http://forum.vibunion.com/forum/thread-43158-1-5.html
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-9-22 21:20 , Processed in 0.062733 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表