GetClosestTimeStamps

PURPOSE ^

GETCLOSESTTIMESTAMPS searches for the closest timestamps within a list.

SYNOPSIS ^

function [closestTimeStamps, closestTimeStampIndices] = GetClosestTimeStamps( searchTimeStamps, timeStampList )

DESCRIPTION ^

 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.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Generated on Thu 08-Apr-2010 14:35:09 by m2html © 2005