CEEMD matlab代码
时间: 2023-11-25 15:37:15 浏览: 88
以下是CEEMD的MATLAB代码,包括CEEMD函数和示例代码:
CEEMD函数:
```
function imf = ceemd(x,NE,Nstd)
% x - input signal (must be a row vector)
% NE - number of ensemble trials
% Nstd - stopping criterion (standard deviation)
% imf - matrix containing the IMFs (one per row)
Nx = length(x);
%---> Define the mean and the stop criterion
meanx = mean(x);
x1 = x - meanx;
if Nstd~=0
stop = Nstd;
else
stop = 0.2;
end
%---> Define the decomposition
imf = zeros(Nx,NE);
for ii=1:NE
xk = x1 + randn(1,Nx);
SD = sqrt(var(xk));
while SD>stop
x1 = xk;
h = x1;
SD = 1;
while SD > 0.3
d=h;
SD=1;
while SD > 0.1
m = floor(length(d)/2);
if m==0
break
end
h1 = d(1:m);
h2 = d(m+1:end);
m1 = mean(h1);
m2 = mean(h2);
h1 = h1 - m1;
h2 = h2 - m2;
h = h1.*h2;
SD = std(h);
if SD==0
break
end
end
if SD==0
break
end
d = d - h;
SD = std(d);
if SD==0
break
end
end
imf(:,ii) = imf(:,ii) + d';
xk = x1 - d;
SD = sqrt(var(xk));
end
end
imf = imf./NE + meanx;
```
示例代码:
```
%---> Generate some data
N = 500;
t = linspace(0,1,N);
x = 3*sin(4*pi*t) + 5*cos(6*pi*t) + randn(1,N);
%---> Perform CEEMD
NE = 100; % Number of ensemble trials
Nstd = 0; % Stopping criterion (standard deviation)
imf = ceemd(x,NE,Nstd);
%---> Plot the results
subplot(2,1,1)
plot(t,x)
title('Original signal')
subplot(2,1,2)
plot(t,imf)
title('Intrinsic mode functions')
```
阅读全文