MATLAB Source Code for Empirical Mode Decomposition (EMD)
- Login to Download
- 1 Credits
Resource Overview
Detailed Documentation
This is a MATLAB source code that performs Empirical Mode De decomposition.
function [IMF,Residual]=emd(x)
%emd: Perform empirical mode decomposition to decompose a signal into Intrinsic Mode Functions (IMFs)
% [IMF,Residual]=emd(x)
%Input:
% x: the input signal (must be a row vector)
%Output:
% IMF: matrix containing intrinsic mode functions as columns
% Residual: the final residual signal after extracting all IMFs
%Author: Deng Bin, Zhang Zhilin
%Date: 4-10-2010
%Reference:
%Norden E. Huang et al, The empirical mode decomposition and the Hilbert spectrum for nonlinear and non-stationary time series analysis, Proc. R. Soc. Lond. A(1998)454:903-995.
%DOI:10.1098/rspa.1998.0193
% Note: This program was written and tested in MATLAB R2016a. Using other MATLAB versions might generate errors or warnings.
% Check if input signal is a vector using size validation
if size(x,1)~=1
error('Input signal must be a row vector');
end
% Initialize IMF matrix with maximum 10 components and working signal
IMF=zeros(length(x),10);
h=x;
n=1;
% Main decomposition loop - iterates up to 10 IMF components
while n<=10
% Stop decomposition when signal length becomes too short (<=3 points)
if length(h)<=3
Residual=h;
break;
end
% Extract envelope using cubic smoothing spline interpolation
% csaps function creates smoothing spline with specified smoothing parameter
p=csaps(1:length(h),h,1-1e-5*(length(h)-1));
m=h-ppval(p,1:length(h))';
% Check if the extracted component meets IMF criteria
if isimf(m)
IMF(:,n)=m';
n=n+1;
h=h-m;
else
h=m;
end
end
% Remove unused IMF columns from the pre-allocated matrix
IMF(:,n:end)=[];
% IMF validation function - checks component properties
function flag=isimf(x)
%isimf: Determine whether x qualifies as an intrinsic mode function
% flag=isimf(x)
%Input:
% x: the candidate signal component
%Output:
% flag: boolean result indicating IMF status (true/false)
%Author: Deng Bin, Zhang Zhilin
%Date: 4-10-2010
%Reference:
%Norden E. Huang et al, The empirical mode decomposition and the Hilbert spectrum for nonlinear and non-stationary time series analysis, Proc. R. Soc. Lond. A(1998)454:903-995.
%DOI:10.1098/rspa.1998.0193
% Initialize flag to true (assume valid IMF initially)
flag=true;
% Check if signal is too short for meaningful IMF analysis
if length(x)<=2
flag=false;
return;
end
% Monotonicity check: verify if signal is strictly increasing or decreasing
if x(1) for i=3:length(x) if x(i-1)>=x(i) flag=false; break; end end else for i=3:length(x) if x(i-1)<=x(i) flag=false; break; end end end % Extremum point balance check: verify equal number of local maxima and minima if sum(x(1:end-2) flag=false; end % Zero signal check: reject components with negligible amplitude if sum(abs(x)) flag=false; end end
- Login to Download
- 1 Credits