Skip to content

Instantly share code, notes, and snippets.

@cdeister
Last active December 12, 2017 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdeister/2b5aaa70457bf72dd6ac3ca879befdd2 to your computer and use it in GitHub Desktop.
Save cdeister/2b5aaa70457bf72dd6ac3ca879befdd2 to your computer and use it in GitHub Desktop.
Matlab script debuging Eric CSV 12/11/2017 Eric needs to sign up for GitHub
%% plot the first write
% 1) plot all
figure(309)
subplot(2,1,1)
plot(aa.psDatatm,aa.psDatav1,'k-','linewidth',1)
% and derivative
hold on
plot(aa.psDatatm(2:end),diff(aa.psDatav1),'r-','linewidth',1)
hold off
% 2) zoom in on a pulse
subplot(2,1,2)
plot(aa.psDatatm,aa.psDatav1,'ko-','linewidth',1)
% and derivative
hold on
plot(aa.psDatatm(2:end),diff(aa.psDatav1),'r-','linewidth',1)
hold off
xlim([990 1020])
%%
sRate=2000;
% a) where are the samples where pulses start and end?
difInds_start=find(diff(aa.psDatav1)>10);
difInds_end=find(diff(aa.psDatav1)<-10);
% b) same but convert to time
difIndTime_start=difInds_start/sRate;
difIndTime_end=difInds_end/sRate;
% c) get pulse width in time and samples now.
pulseSamps=difInds_end-difInds_start;
pulseTimes=difIndTime_end-difIndTime_start;
% one sample more than we wanted 0.0505, but each one is 1 sample more.
% d) how about dwell times?
dwellSamps=diff(difInds_start)-pulseSamps(1:end-1)
% i get 10 samples, which is right. So, the pulse had one extra sample.
% But, they were all 1 extra sample, so no systematic error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment