GETCLOSESTTIMESTAMPS searches for the closest timestamps within a list. GETCLOSESTTIMESTAMPS accepts two inputs. The first is a vector of the original timestamps and the other is a list of timestamps. The function extracts from the list the timestamps closest to the those in the original vector.
0001 function [closestTimeStamps, closestTimeStampIndices] = GetClosestTimeStamps( searchTimeStamps, timeStampList ) 0002 % GETCLOSESTTIMESTAMPS searches for the closest timestamps within a list. 0003 % 0004 % GETCLOSESTTIMESTAMPS accepts two inputs. The first is a vector of the 0005 % original timestamps and the other is a list of timestamps. The function 0006 % extracts from the list the timestamps closest to the those in the 0007 % original vector. 0008 closestTimeStamps=zeros(size(searchTimeStamps)); 0009 closestTimeStampIndices=zeros(size(searchTimeStamps)); 0010 for i=1:length(searchTimeStamps) 0011 [minimum,closestTimeStampIndices(i)] = min( abs(timeStampList-searchTimeStamps(i)) ); 0012 closestTimeStamps(i) = timeStampList(closestTimeStampIndices(i)); 0013 end