-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmean_env_experiment.m
executable file
·72 lines (53 loc) · 1.56 KB
/
mean_env_experiment.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
L = 400;
x = linspace(0,6,L);
fs = round(L./x(end));
delta_x = 6 ./ L;
% % Three sinusoids
signal = 5*cos(2*pi*x) + 20*cos(0.1*pi*x) + 10*cos(0.5*pi*x);
% signal_pp = -20*pi^2*cos(2*pi*x) - 0.2*pi^2*cos(0.1*pi*x) - 2.5*pi^2*cos(0.5*pi*x);
% load('./data/ECG-data/ECG-data');
% signal = sig_sample_1';
% L = length(signal);
% x = linspace(0,6,L);
signal_pp = diff(signal, 2) ./ (delta_x)^2;
new_sig = signal(3:end);
% signal = sin(4*pi.*[x(1:L/2) zeros(1,L/2)] ) + ...
% sin(24*pi.*[zeros(1,L/2) x(L/2+1:end)]);
% Constant parameter
c = 1./(4*pi^2);
mean_env = new_sig + c.* signal_pp;
% % Detected Parameter
% [indmin, indmax, indzero] = extr(signal);
% min_dist = min(diff(indmax)) * (x(end)./length(x));
% c = 1./(2*pi./min_dist).^2;
% mean_env = new_sig + c.* signal_pp;
% % piecewise constant
% indices = inflection(x, signal);
% indices = [1 indices];
% mean_env = zeros(1, length(signal));
% c = zeros(1, length(signal));
% for i = 1:length(indices)-1
% for j = indices(i): indices(i+1)
% c(j) = (x(indices(i+1)) - x(indices(i)))^2 ./ pi^2;
% end
% end
% c = c(2:end-1);
% mean_env = new_sig + c.* signal_pp;
% % piecewise constant
% indices = inflection(x, signal);
% indices = [1 indices];
% mean_env = zeros(1, length(signal));
% c = zeros(1, length(signal));
% for i = 1:length(indices)-1
% for j = indices(i): indices(i+1)
% c(j) = (x(indices(i+1)) - x(indices(i)))^2 ./ pi^2;
% end
% end
% c = c(2:end-1);
% mean_env = new_sig + c.* signal_pp;
% C as a variable
% what kind of variable?
figure;
hold on;
plot(new_sig);
plot(mean_env);