声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2155|回复: 12

[公告] 发现emd程序中求极值点有问题

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

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

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

x
本帖最后由 wdhd 于 2016-9-13 14:10 编辑

  while SD > 0.3
  % 找极值点
  d = diff(h);
  % approximate derivative
  maxmin = [];
  for i=1:N-2
  if d(i)==0
  % we are on a zero
  maxmin = [maxmin, i];
  elseif sign(d(i))~=sign(d(i+1))
  % we are straddling a zero so
  maxmin = [maxmin, i+1];
  % define zero as at i+1 (not i)
  end
  end
  if size(maxmin,2) < 2
  % 极值点数目小于2个跳出循环
  break
  %(maxmin,2)中的2代表列数即极值点数
  end
  % divide maxmin into maxes and mins
  if maxmin(1)>maxmin(2)
  % first one is a max not a min
  maxes = maxmin(1:2:length(maxmin));
  mins
  = maxmin(2:2:length(maxmin));
  else
  % is the other way around
  maxes = maxmin(2:2:length(maxmin));
  mins
  = maxmin(1:2:length(maxmin));
  end
  % 极值点的位置信息
  maxes = [1 maxes N];
  mins
  = [1 mins
  N];
  这个程序,其中请主要关注这两个地方
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  for i=1:N-2
  if d(i)==0
  % we are on a zero
  maxmin = [maxmin, i];
  elseif sign(d(i))~=sign(d(i+1))
  % we are straddling a zero so
  maxmin = [maxmin, i+1];
  % define zero as at i+1 (not i)
  end
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  if maxmin(1)>maxmin(2)
  % first one is a max not a min
  maxes = maxmin(1:2:length(maxmin));
  mins
  = maxmin(2:2:length(maxmin));
  else
  % is the other way around
  maxes = maxmin(2:2:length(maxmin));
  mins
  = maxmin(1:2:length(maxmin));
  end
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  请问这个判断maxmin(1)>maxmin(2) 是不是多余的?
回复
分享到:

使用道具 举报

发表于 2007-5-5 09:25 | 显示全部楼层
这个应该是为极值延拓准备的
 楼主| 发表于 2007-5-5 12:14 | 显示全部楼层
这个判断maxmin(1)>maxmin(2)条件是不是恒为真?下面的程序每次都执行
maxes = maxmin(1:2:length(maxmin));
mins
= maxmin(2:2:length(maxmin));
这两句,但对求包络结果没有影响,因此可以简化只有这两句
maxes = maxmin(1:2:length(maxmin));
mins
= maxmin(2:2:length(maxmin));
不知我这样分析对不对?
发表于 2007-5-5 13:41 | 显示全部楼层
这个不是Rilling的程序,是自己写的?没有上下文,谁也看不懂。
 楼主| 发表于 2007-5-5 14:48 | 显示全部楼层

回复 #4 playfish 的帖子

% EMD:  Emprical mode decomposition
%
% imf = emd(x)
%
% x   - input signal (must be a column vector)
%
% This version will calculate all the imf's (longer)
%
% imf - Matrix of intrinsic mode functions (each as a row)
%       with residual in last row.
%
% See:  Huang et al, Royal Society Proceedings on Math, Physical,
%       and Engineering Sciences, vol. 454, no. 1971, pp. 903-995,
%       8 March 1998
%
% Author: Ivan Magrin-Chagnolleau  <ivan@ieee.org>
%

function imf=emd(x);

c = x(:)'; % copy of the input signal (as a row vector)
N = length(x);

%-------------------------------------------------------------------------
% loop to decompose the input signal into successive IMF

imf = []; % Matrix which will contain the successive IMF, and the residue

while (1) % the stop criterion is tested at the end of the loop
   
   %-------------------------------------------------------------------------
   % inner loop to find each imf
   
   h = c; % 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
      % while the standard deviation is higher than 0.3 (typical value)
      
      % find local max/min points
      d = diff(h); % approximate derivative
      maxmin = []; % to store the optima (min and max without distinction so far)
      for i=1:N-2
         if d(i)==0                        % we are on a zero
            maxmin = [maxmin, i];
         elseif sign(d(i))~=sign(d(i+1))   % we are straddling a zero so
            maxmin = [maxmin, i+1];        % define zero as at i+1 (not i)
         end
      end
      
      if size(maxmin,2) < 2 % then it is the residue
         break
      end
      
      % divide maxmin into maxes and mins
      if maxmin(1)>maxmin(2)              % first one is a max not a min
         maxes = maxmin(1:2:length(maxmin));
         mins  = maxmin(2:2:length(maxmin));
      else                                % is the other way around
         maxes = maxmin(2:2:length(maxmin));
         mins  = maxmin(1:2:length(maxmin));
      end
      
      % make endpoints both maxes and mins
      maxes = [1 maxes N];
      mins  = [1 mins  N];
      
      
      %-------------------------------------------------------------------------
      % spline interpolate to get max and min envelopes; form imf
      maxenv = spline(maxes,h(maxes),1:N);
      minenv = spline(mins, h(mins),1:N);
      
      m = (maxenv + minenv)/2; % mean of max and min enveloppes
      prevh = h; % copy of the previous value of h before modifying it
      h = h - m; % substract mean to h
      
      % calculate standard deviation
      eps = 0.0000001; % to avoid zero values
      SD = sum ( ((prevh - h).^2) ./ (prevh.^2 + eps) );
      
   end
   
   imf = [imf; h]; % 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
   
   c = c - h; % substract the extracted IMF from the signal
   
end

return


这是完整的,我说的那个地方是不是存在这个问题?
请教。
发表于 2007-5-5 17:29 | 显示全部楼层
就程序看,maxmin是所有的极值点序列。maxmin(1)>maxmin(2)是看第一个点是极大值还是极小值。以后这种让人帮助分析程序的帖子不要拿到这里贴,这是自己应该做的工作。今天我心情好,碰到eight兄估计你要挨骂了。
发表于 2007-5-5 18:22 | 显示全部楼层
本帖最后由 wdhd 于 2016-9-13 14:10 编辑
原帖由 playfish 于 2007-5-5 17:29 发表
就程序看,maxmin是所有的极值点序列。maxmin(1)>maxmin(2)是看第一个点是极大值还是极小值。以后这种让人帮助分析程序的帖子不要拿到这里贴,这是自己应该做的工作。今天我心情好,碰到eight兄估计你要挨骂了。


呵呵,不要这样子吓唬这些新手,我又不是母老虎,怎么会到处骂人呢?我的出发点只是希望大家自己多动手,不然总是跟着别人的步子走,哪有进步?
 楼主| 发表于 2007-5-5 20:31 | 显示全部楼层

回复 #6 playfish 的帖子

这个判断maxmin(1)>maxmin(2)条件是不是恒为真?
 楼主| 发表于 2007-5-5 20:31 | 显示全部楼层

回复 #7 eight 的帖子

这个判断maxmin(1)>maxmin(2)条件是不是恒为真?
 楼主| 发表于 2007-5-5 20:35 | 显示全部楼层
唉!怎么不看我问的是什么呢?
这个判断maxmin(1)>maxmin(2)条件是不是恒为真?
如果恒为真,那么下面的if……else就有些多余了
发表于 2007-5-5 23:21 | 显示全部楼层
本帖最后由 wdhd 于 2016-9-13 14:10 编辑
原帖由 liliang 于 2007-5-5 20:35 发表
唉!怎么不看我问的是什么呢?
这个判断maxmin(1)>maxmin(2)条件是不是恒为真?
如果恒为真,那么下面的if……else就有些多余了


个人认为应该恒为假。如果按照注释,程序的编写应该有问题
 楼主| 发表于 2007-5-6 12:10 | 显示全部楼层
:loveliness:
对对,是恒为假,但是不会影响运行结果,因为极大与极小值点的位置是交叉存放在maxmin矩阵中的。这样认为应该没有错吧?
发表于 2008-12-24 19:27 | 显示全部楼层
本帖最后由 wdhd 于 2016-9-13 14:10 编辑

  请问一下这个程序中的for i=1:N-2是干嘛的?
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-4-29 10:08 , Processed in 0.053694 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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