diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2012-12-11 15:23:02 -0500 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2012-12-11 15:23:02 -0500 |
commit | d3776bb6077baa0d8e2a38a8dd84fcedc841b51c (patch) | |
tree | 197e7becf30912a35891eacb902067618f60fd6b | |
parent | 2eb286e6bf5e87f7159387af191b41a38868bd88 (diff) | |
download | Nresonances-d3776bb6077baa0d8e2a38a8dd84fcedc841b51c.tar.gz Nresonances-d3776bb6077baa0d8e2a38a8dd84fcedc841b51c.zip |
added new functions to extract delay times
-rw-r--r-- | xmds2/realistic_Rb_and_fields/field_delay.m | 30 | ||||
-rw-r--r-- | xmds2/realistic_Rb_and_fields/find_pulse_center.m | 11 |
2 files changed, 41 insertions, 0 deletions
diff --git a/xmds2/realistic_Rb_and_fields/field_delay.m b/xmds2/realistic_Rb_and_fields/field_delay.m new file mode 100644 index 0000000..6f2de6e --- /dev/null +++ b/xmds2/realistic_Rb_and_fields/field_delay.m @@ -0,0 +1,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); + + diff --git a/xmds2/realistic_Rb_and_fields/find_pulse_center.m b/xmds2/realistic_Rb_and_fields/find_pulse_center.m new file mode 100644 index 0000000..11b3395 --- /dev/null +++ b/xmds2/realistic_Rb_and_fields/find_pulse_center.m @@ -0,0 +1,11 @@ +function [pc, pc_err] = find_pulse_center(x,y) + +f=fittype(@(A,x0,width, x) A.*exp(-((x-x0)/width).^2) ); +pin=[1e4, 0, .4e-6]; % A, x0, width + +[fitobject,gof] = fit (x, y, f, 'StartPoint', pin); +ci = confint(fitobject); + +coefi=2; %x0 +pc = (ci(2,coefi) + ci(1,coefi))/2; +pc_err = (ci(2,coefi) - ci(1,coefi))/2; |