python实现
这是经验模式分解(EMD)的另一种Python实现。该包包含许多EMD变体,并打算及时交付更多。
from PyEMD import EMD
import numpy as np
s = np.random.random(100)
emd = EMD()
IMFs = emd(s)
https://github.com/laszukdawid/PyEMD
matlab实现
代码1:
function [imf,r] = emd(x)
% Empiricial Mode Decomposition (Hilbert-Huang Transform)
% imf = emd(x)
% Func : findpeaks
% 返回类型为cell类型,
% IMF第一列为原始信号,一次为一次IMF,二次IMF、。。。、最后残差
x = transpose(x(:));
imf = x';
while ~ismonotonic(x) % 若信号x不单调,则开始进行emd分解
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 &