To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Revision:

root / _beattracker / refineperiod.m @ 8:b5b38998ef3b

History | View | Annotate | Download (1.01 KB)

1
function period = refineperiod(period,acf,timesig);
2

    
3

    
4
if ~timesig, timesig=4; end
5

    
6
% peaks = zeros(1,timesig);
7
% ind = period;
8
% for i=1:timesig
9
%     segment = acf(ind*i-(i-1):ind*i+(i-1));
10
%     [val,loc] = max(segment);
11
%     peaks(i) = loc + ind*i-(i-1)-1;
12
% end
13
% 
14
% 
15
% for i=1:timesig
16
%     peaks(i) = (peaks(i)-1)/i;
17
% end
18
% 
19
% period = mean(peaks);
20
% 
21
% 
22

    
23

    
24

    
25

    
26

    
27
% 
28
% 
29
if ~timesig
30
    timesig =4;
31
end
32

    
33
ind = period;
34

    
35
if (timesig==4)
36
    peak = zeros(1,4);
37

    
38
    peak(1) = ind;
39

    
40
    [val2,ind2] = max(acf(2*ind-1:2*ind+1));
41
    peak(2) = ind2 + 2*ind-2;
42

    
43
    [val3,ind3] = max(acf(3*ind-2:3*ind+2));
44
    peak(3) = ind3 + 3*ind-4;
45

    
46
    [val4,ind4] = max(acf(4*ind-3:4*ind+3));
47
    peak(4) = ind4 + 4*ind-9;
48

    
49
    period = mean([ peak(1) peak(2)/2 peak(3)/3 peak(4)/4 ]);
50

    
51
else
52

    
53
    peak = zeros(1,3);
54

    
55
    peak(1) = ind;
56

    
57
    [val2,ind2] = max(acf(2*ind-1:2*ind+1));
58
    peak(2) = ind2 +2*ind-2;
59

    
60
    [val3,ind3] = max(acf(3*ind-2:3*ind+2));
61
    peak(3) = ind3 + 3*ind-4;
62

    
63
    period = mean([ peak(1) peak(2)/2 peak(3)/3 ]);
64

    
65
end