-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathexample_whitenoise_fig4.m
114 lines (91 loc) · 3.13 KB
/
example_whitenoise_fig4.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
%%
% Example of Online EMD with two long signals: a sinusoid and white noise
%
% Note that the maximum number of sifting in emdc.c must be increased
% to analyze such long signals.
%%
clear all; close all; clc;
nbExec = 100;
step = 10000;
exec = zeros(4,nbExec);
emdLabel = {'Online EMD','EMD'};
% white noise
x1=randn(1,1100000);
% Toy signal
samp = pi/2:.5:550000;
comp1 = sin(samp);
trend = linspace(0,10000,length(samp));
x2 = comp1 + trend;
for emdFct = 1:2
emdLabel{emdFct}
for signal = 1:2
signal
if signal == 1
x = x1;
else
x = x2;
end
%% Initialization of Online EMD
if emdFct == 1
% Parameters
nbExtrema = 20; % Size of the sliding window (number of extrema per window) (must be higher than 10)
nbMaxIMF = -1; % Number of IMFs to extract (-1 for unlimited)
if signal == 2
nbMaxIMF = 1;
end
% Initialization
stage = oemd_init(nbMaxIMF,nbExtrema,0); %Initializate data structures
else
nbMaxIMF=0;
if signal == 2
nbMaxIMF = 1;
end
end
%% Execution
for i = 1:nbExec
t = cputime;
if emdFct == 1
stage(1).data = [stage(1).data x(1+(i-1)*step:i*step)]; %add new samples to the stream
stage = oemd_iter(stage); %iterate
else
% for the classical EMD we look at each execution time
[imf, nbIter] = emdc([],x(1:i*step),[],nbMaxIMF);
% [imf] = emd(x(1:i*step),'FIX_H',4);
end
exec(2*(emdFct-1)+signal,i) = cputime-t;
end
% plotIMFs(stage,0);
end
end
%% Plot the excution times
figure()
for emdFct = 1:2
for signal = 1:2
if emdFct == 1
if signal ==1
semilogy(step:step:nbExec*(step+1),exec(2*(emdFct-1)+signal,:),'-ro','DisplayName',[emdLabel{emdFct} ': White Noise'],'LineWidth',3,'MarkerSize',8);
else
hold on
semilogy(step:step:nbExec*(step+1),exec(2*(emdFct-1)+signal,:),'-r+','DisplayName',[emdLabel{emdFct} ': Sin+trend'],'LineWidth',3,'MarkerSize',8);
end
else
if signal ==1
semilogy(step:step:nbExec*(step+1),exec(2*(emdFct-1)+signal,:),'-bo','DisplayName',[emdLabel{emdFct} ': White Noise'],'LineWidth',3,'MarkerSize',8);
else
hold on
semilogy(step:step:nbExec*(step+1),exec(2*(emdFct-1)+signal,:),'-b+','DisplayName',[emdLabel{emdFct} ': Sin+trend'],'LineWidth',3,'MarkerSize',8);
end
end
end
end
legend('show','Location','Best');
grid on;
turn the grid gray
set(gca,'XMinorGrid','Off');
set(gca,'Xcolor',[0.5 0.5 0.5]);
set(gca,'Ycolor',[0.5 0.5 0.5]);
Caxes = copyobj(gca,gcf);
set(Caxes, 'color', 'none', 'xcolor', 'k', 'xgrid', 'off', 'ycolor','k', 'ygrid','off');
ylabel('Execution Time (seconds)','Color','k');
xlabel('Number of samples','Color','k');
print('whitenoise_execTime.eps','-depsc');