function [beat,tb,xbeat]=fanal(t,x) %% Carol Lucas %% Function called to pick out beats (frequency analysis) from vector x %% Uses simple zero crossing technique. %% beat = length of time for the beat %% tb=time selected for start of beat %% xvalue at that time sfill=1; xmean=mean(x); x=x-xmean; %% TAKE MEAN OUT TO GET ZERO CROSSINGS AT MEAN beat=0*t; tb(1)=0; xbeat(1)=xmean; np=1; for k=1:length(t)-1 if and(x(k)<=0,x(k+1)>=0) for n=sfill:k beat(n)=t(k)-t(sfill); end; sfill=k; tb(np)=t(k); xbeat(np)=x(k)+xmean; np=np+1; end end