-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneeemd.m
49 lines (43 loc) · 1.34 KB
/
neeemd.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
% y=xlsread('some.data'); % load a signal.
% num_IMF = 5; % numbers of IMF
% NR = 10; % value of ensemble
% NstdMax = 0.2; % upper bound
% NstdMin = 0.1 % lower bound
% IMF1=eemd(y,num_IMF,NR,Nstd);
function [Fimfs, residual] = neeemd(y, num_IMF, NR, NstdMax, NstdMin)
stdy = std(y);
if stdy < 0.01
stdy = 1;
end
y = y ./ stdy;
siz = length(y);
modes = zeros(siz,num_IMF);
res = zeros(siz,1);
for k = 1:NR
disp(['Ensemble number #' num2str(k)]);
Nstd = (NstdMax-NstdMin).*rand(1,1) + NstdMin; % Generating random std of white noise
x = randn(siz,1);
x = x - mean(x); % genrating 0 mean and 1 std
x = x -std(x);
wn{k} = x.*Nstd;
noise{1,k} = wn{k};
y1 = y + wn{k};
[imf, resN] = emd(y1,'MaxNumIMF',num_IMF); % obtaining IMFs and residuals
modes = modes + imf;
res = res + resN;
end
modes = modes .* stdy ./ (NR); % IMFs from EEMD
res = res ./ NR; % Final residuals
% dealing with the noise
Nimfs = zeros(siz,num_IMF);
nres = zeros(siz,1);
for i = 1:NR
[nimfs, nresN] = emd(noise{1,i},'MaxNumIMF',num_IMF);
Nimfs = Nimfs+nimfs;
nres = nres + nresN;
end
Nimfs = Nimfs./NR; % IMFs of noise
Fimfs = modes - Nimfs; % Final IMFs of nEEEMD.
nres = nres ./ NR; % Noise residual
residual = res - nres; % Residue of signal
end