summaryrefslogtreecommitdiff
path: root/xmds2/realistic_Rb_and_fields/field_delay.m
blob: 6f2de6ed989bac4cc6d8715d31966d34d88127d5 (plain)
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
realistic_Rb_and_fields;

dt=mean(diff(t_1));
Ip2_b = Ip2_out_1(:,1);
Ip2_a = Ip2_out_1(:,end);

[c, lags] = xcov(Ip2_a, Ip2_b);
[m, i] = max(c);

delay_time = dt*lags(i);

% delay in nS
str= sprintf('delay_time_with_xcov= %f nS', 1e9*delay_time);
disp(str);


[pcenter_b, perr_b] = find_pulse_center(t_1', Ip2_b);
[pcenter_a, perr_a] = find_pulse_center(t_1', Ip2_a);

delay_time = pcenter_a - pcenter_b;
delay_time_err = sqrt( perr_a^2 + perr_b^2);


str= sprintf('delay_time_with_fit= %f nS', 1e9*delay_time);
disp(str);

str= sprintf('delay_time_error_with_fit= %f nS', 1e9*delay_time_err);
disp(str);