%此版本为ALAN 版本的整合注释版标签:emd,end,imf,分解,x2,x1,sd From: https://blog.51cto.com/u_15815923/5744743
function imf = emd(x)
% Empiricial Mode Decomposition (Hilbert-Huang Transform)
% imf = emd(x)
% Func : findpeaksx= transpose(x(:));%转置为行矩阵
imf = [];while ~ismonotonic(x) %当x不是单调函数,分解终止条件
x1 = x;
sd = Inf;%均值
%直到x1满足IMF条件,得c1
while (sd > 0.1) | ~isimf(x1) %当标准偏差系数sd大于0.1或x1不是固有模态函数时,分量终止条件
s1 = getspline(x1);%上包络线
s2 = -getspline(-x1);%下包络线
x2 = x1-(s1+s2)/2;%此处的x2为文章中的h
sd = sum((x1-x2).^2)/sum(x1.^2);
x1 = x2;
end
imf{end+1} = x1;
x = x-x1;
endimf{end+1} = x;