function out=legTrackerInterPeakDist(data) %legTrackerInterPeakDists determines the distribution of intervals between %local minima and maxima in time series data. Used in Figs S2b and 3h %(rows 2 and 4). %Usage: %out=legTrackerInterPeakDist(data) %data = vector of ball motion or leg position time series data. %declare temp to store inter-peak intervals as they are identified temp=[]; %is the time series going up or down from frame 1 to 2? if data(1)data(i+1) %record peak position, switch to down mode peak=i; peakhit=1; upBool=0; % if peak and valley now both detected if peakhit==1 && valleyhit==1; % record interval temp=[temp;data(peak)-data(valley)]; end end else % if now going up if data(i)