MATLAB: How to interpolate to the nearest value

integrationinterpolation

HI
I have vector, v=(x,Y) and I want to find the nearest value of 'x' for C=(1,yi) rather than the interpolated values of xi's .I can find the interpolated value but taking the nearest values of x is difficult for me. Can you help me with this?

Best Answer

If you look at the documentation of interp1, you'll see that nearest neighbor interpolation is an option:
interp1(x,y,xi, 'nearest')