x = {'05:05:05', '05:05:06', '05:05:09', '05:05:10'}
p='05:05:07'
xx=datenum(x)
pp=datenum(p)
[~,idx]=min(abs(xx-pp))
out=x(idx) % the nearest time and idx is its corresponding index
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!