发现emd程序中求极值点有问题
本帖最后由 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 = ;
elseif sign(d(i))~=sign(d(i+1))
% we are straddling a zero so
maxmin = ;
% 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 = ;
mins
= [1 mins
N];
这个程序,其中请主要关注这两个地方
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:N-2
if d(i)==0
% we are on a zero
maxmin = ;
elseif sign(d(i))~=sign(d(i+1))
% we are straddling a zero so
maxmin = ;
% 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) 是不是多余的?
这个应该是为极值延拓准备的 这个判断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));
不知我这样分析对不对? 这个不是Rilling的程序,是自己写的?没有上下文,谁也看不懂。
回复 #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 = ;
elseif sign(d(i))~=sign(d(i+1)) % we are straddling a zero so
maxmin = ; % 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 = ;
mins= ;
%-------------------------------------------------------------------------
% 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 = ; % 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
这是完整的,我说的那个地方是不是存在这个问题?
请教。 就程序看,maxmin是所有的极值点序列。maxmin(1)>maxmin(2)是看第一个点是极大值还是极小值。以后这种让人帮助分析程序的帖子不要拿到这里贴,这是自己应该做的工作。今天我心情好,碰到eight兄估计你要挨骂了。 本帖最后由 wdhd 于 2016-9-13 14:10 编辑
原帖由 playfish 于 2007-5-5 17:29 发表
就程序看,maxmin是所有的极值点序列。maxmin(1)>maxmin(2)是看第一个点是极大值还是极小值。以后这种让人帮助分析程序的帖子不要拿到这里贴,这是自己应该做的工作。今天我心情好,碰到eight兄估计你要挨骂了。
呵呵,不要这样子吓唬这些新手,我又不是母老虎,怎么会到处骂人呢?我的出发点只是希望大家自己多动手,不然总是跟着别人的步子走,哪有进步?
回复 #6 playfish 的帖子
这个判断maxmin(1)>maxmin(2)条件是不是恒为真?回复 #7 eight 的帖子
这个判断maxmin(1)>maxmin(2)条件是不是恒为真? 唉!怎么不看我问的是什么呢?这个判断maxmin(1)>maxmin(2)条件是不是恒为真?
如果恒为真,那么下面的if……else就有些多余了 本帖最后由 wdhd 于 2016-9-13 14:10 编辑
原帖由 liliang 于 2007-5-5 20:35 发表
唉!怎么不看我问的是什么呢?
这个判断maxmin(1)>maxmin(2)条件是不是恒为真?
如果恒为真,那么下面的if……else就有些多余了
个人认为应该恒为假。如果按照注释,程序的编写应该有问题 :loveliness:
对对,是恒为假,但是不会影响运行结果,因为极大与极小值点的位置是交叉存放在maxmin矩阵中的。这样认为应该没有错吧? 本帖最后由 wdhd 于 2016-9-13 14:10 编辑
请问一下这个程序中的for i=1:N-2是干嘛的?
页:
[1]