MATLAB: How to choose the closest acceleration value from excel table

closest value

Hey guys,
So I have a 6×6 diagonal matrix which gives time period:
time= [0.0015 0 0 0 0 0; 0 0.0035 0 0 0 0; 0 0 0.0050 0 0 0; 0 0 0 0.0064 0 0; 0 0 0 0 0.0078 0; 0 0 0 0 0 0.0092]
I wanna be able to take the time value, for example 0.0015 and get acceleration 0.79545 (notice that our matrix gives value, 0.0015 but we only have data for 0.00149 (the closest), so we use this. For next time value 0.0035 we would want 0.76733, which is the acceleration for 0.0037s (the closest). I am quite new to matlab and all help would be appreciated!
table=[0.00149 0.795;0.00370 0.767;0.00495 1.02;0.0063 1.39;0.0078 1.73;0.0092 2.01]

Best Answer

interp1(table(:,1), table(:,2), diag(time), 'nearest')