How to do interpolation with interp1 and does this relate to binning?

4 views (last 30 days)
Hi I have some data collected from track runners who ran around a 400 meter track multiple times for multiple training days. Many measurements of a given track runner's velocity were taken at various locations along the track (e.g. at 201.33 m, at 2.04 m, etc) and the number of these measurements varied for each run around the track. I want to plot the average velocity of all runners with respect to location on the track. However, since the velocity measurements varied so much with respect to position and the number of measurements varied, I need a way to group the velocity measurements together and predict the velocity at a specific location along the track. I.e., I need a way to predict the velocity at 0 m, 1 m, 2 m, .... , 400 m so that I get a smoother, easier to read curve. I'm thinking of using a combination of binning and interpolation but I don't really know how to start. Any suggestions are appreciated!!
Lastly, I was looking into the interp1 function and I don't really understand what 'query points' are. Can anyone explain? Thank you!!!

Answers (1)

Walter Roberson
Walter Roberson on 28 Aug 2021
interp1() has you pass in a (possibly implicit) x, and a set of associated y values that give the value of some unknown function at known points. And the question for interp1() is "supposing that those given points are samples from a continuous function, then what value of the function would you predict at these particular points?" -- the query points. The query points are the placed to interpolate at. In your case, the 0m, 1m, 2m, and so on.
The default continuous function for interp1() is "linear": that any two adjacent known points are joined by a straight line. Other common approximating functions to tell interp1() to use are "previous" (if the query is at a known point, use the known point, otherwise use the value of the closest known point before it) or "next" (if the query is at a known point, use the known point, otherwise use the value of the closest known point after it), and "spline" ("Spline interpolation using not-a-knot end conditions. The interpolated value at a query point is based on a cubic interpolation of the values at neighboring grid points in each respective dimension.") with a couple of others also being possible.
interp1() does use binning in a sense, in order to figure out which segment the query points fall on relative to the given points, to know which values to use for the interpolation.
My understanding is that runners do not tend to accelerate linearly -- that if they are measured at 15 km/h at 50 m, and 17 km/h at 100m, that they probably did not go through 16 km/h at 75m . That they tend to run at a mostly steady rate but go through periods of acceleration or deceleration and then run at the new rate. So I am not convinced that linear or spline interpolation would meaningfully represent your data -- tansig for example might be more natural. But... if you do not have frequent enough measurements then you do not know where the acceleration periods are, and that could be a problem.

Categories

Find more on Interpolation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!