本站所有资源均为高质量资源,各种姿势下载。
以下是一个可以行经验模式分解的 MATLAB 源程序。
function [IMF,Residual]=emd(x)
%emd:Perform empirical mode decomposition.
% [IMF,Residual]=emd(x)
%Input:
% x:the input signal.
%Output:
% IMF:the intrinsic mode function.
% Residual:the final residual.
%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
% 请注意,此程序是在 MATLAB R2016a 中编写和测试的。如果您使用其他版本的 MATLAB,可能会遇到错误或警告。
% 检查输入信号是否为向量
if size(x,1)~=1
error('Input signal must be a row vector');
end
% 初始化
IMF=zeros(length(x),10);
h=x;
n=1;
% 分解
while n<=10
% 分解到最后一层,剩余信号即为最终残差
if length(h)<=3
Residual=h;
break;
end
% 对信号进行包络线的提取和插值
p=csaps(1:length(h),h,1-1e-5*(length(h)-1));
m=h-ppval(p,1:length(h))';
% 判断信号是否为 IMF
if isimf(m)
IMF(:,n)=m';
n=n+1;
h=h-m;
else
h=m;
end
end
% 去除未使用的 IMF
IMF(:,n:end)=[];
% IMF 判断函数
function flag=isimf(x)
%isimf:Determine whether x is a (monotonic) intrinsic mode function or not.
% flag=isimf(x)
%Input:
% x:the input signal.
%Output:
% flag:the judgment result.
%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
% 初始化
flag=true;
% 判断是否为单峰函数
if length(x)<=2
flag=false;
return;
end
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 % 判断极值点数量是否相等 if sum(x(1:end-2) flag=false; end % 判断是否为零 if sum(abs(x)) flag=false; end end