Let's say I have a signal with a sampling rate of 4ms. for example:-
time index value
0 0 15
4 1 17
8 2 4
12 3 71
16 4 54
20 5 21
and, I have a time value that defines which value I want to access. for example I want to know what the value at time 17.9834ms is. The naive way would be to just match the time 17.9834ms to the nearest known value (16ms). Which is not what I want.
The other way would be to use interpolation. I implemented linear interpolation and it works alright but the appropriate shape for interpolation would be a polynomial not a straight line. I want to know how to get the best approximation for the value at 17.9834ms. I looked at using sinc filter, but I did not understand.
Could someone help with this? Thanks.
Choosing the nearest value is actually interpolation; it's called nearest neighbor interpolation.
Linear interpolation is a very fine way to go.
There are actually a plethora of ways to interpolate. Sinc interpolation multiplies each value that you have with a sinc function (where $sinc(x) = sin(x)/x$) and then sums up all those functions at the point that you're interested in. This interpolation is perfect if your signal was band limited and your sample rate was greater than the bandwidth.
If you feel like you want something smoother than linear interpolation, cubic-spline interpolation is a good way to go. It ensures that the derivative of your resulting function is continuous.