-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcummeannoise.m
29 lines (24 loc) · 858 Bytes
/
cummeannoise.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
function [sigmais] = cummeannoise(noisedata)
sigmais = [];
mui = 0;
for itr = 1:size(noisedata,2);
s = noisedata(:,itr);
%Find the index of the max amplitude of signal s
minidx = find(s==min(s));
minidx = minidx(1);
maxidx = find(s==max(s));
maxidx = maxidx(1);
if(abs(s(maxidx)) < abs(s(minidx)))
maxidx = minidx;
end
%Calculate cumulative mean up to that point
currentPoint = (itr-1)*1000;
for jtr = 1:maxidx-1
mui = (currentPoint + jtr-1) * mui / (currentPoint + jtr) + s(jtr)/(currentPoint +jtr);
end
sigmais = [sigmais s(maxidx)-mui];
for jtr = maxidx:1000
mui = (currentPoint + jtr-1) * mui / (currentPoint + jtr) + s(jtr)/(currentPoint +jtr);
end
end
end