其中ξ(t)就是原始信號,IMFi就是K個固有模態函數。rK就是原始信號減完IMF后剩下的余項。
下面是求解EMD算法的Matlab源程序,特此聲明,本程序為我本人在網上找到的,除了注釋外,其他版權皆歸屬原作者,由于不清楚原作者是誰,未能標出,如果侵犯權利,請聯系我刪除源碼。
%非主函數,被調用
function n = findpeaks(x)%用于尋找極值點,該函數只會求極大值
% Find peaks.
% n = findpeaks(x)
n = find(diff(diff(x)>0)<0);%一階導數大于0二階導數小于0的點
u = find(x(n+1)>x(n));
n(u) = n(u) + 1;
end
%非主函數,被調用<br>%判斷x是否單調,返回0代表不是單調,返回1代表是單調
function u = ismonotonic(x)
u1 = length(findpeaks(x))*length(findpeaks(-x));%如果最大/最小值有一個為0即可判斷程序滿足退出條件了
if u1 > 0
u = 0;
else
u = 1;
end
end
%非主函數,被調用。判斷當前x是不是真IMF
function u = isimf(x)
N = length(x);
u1 = sum(x(1:N-1).*x(2:N) < 0);%求x與y=0軸交點的個數
u2 = length(findpeaks(x))+length(findpeaks(-x));%求極值點個數
if abs(u1-u2) > 1
u = 0;
else
u = 1;
end
end
%非主函數,被調用,作用是獲得x的包絡線
function s = getspline(x)
N = length(x);
p = findpeaks(x);
s = spline([0 p N+1],[0 x(p) 0],1:N);
end
%主函數
function imf = emd(x)
% Empiricial Mode Decomposition (Hilbert-Huang Transform)
% imf = emd(x)
% Func : findpeaks
x = transpose(x(:));
imf = [];
while ~ismonotonic(x)
x1 = x;
sd = Inf;
while (sd > 0.1) || ~isimf(x1)
s1 = getspline(x1);
s2 = -getspline(-x1);
x2 = x1-(s1+s2)/2;
sd = sum((x1-x2).^2)/sum(x1.^2);
x1 = x2;
end
imf(end+1,:) = x1;
x = x-x1;
end
imf(end+1,:) = x;
end
Section IV Hilbert算法的介紹
在上一章中,我們介紹了EMD算法,在這一部分中,我會介紹Hilbert算法,這一節有些許數學趣味,對數學趣味不感興趣的直接跳到應用部分。