# Linear interpolation between multiple points

I have a set of points ( temperature, timestamp) I'm doing linear interpolation between those points and ramping. I would like to know how to use relative time instead of absolute time

deltaT = setPoint[y].time - setPoint[x].time;

t = t + 1/deltaT;

rOut = (1 - t) * setPoint[x].Temp + t * setPoint[y].temp;

• What do you mean by "use relative time instead of absolute time"? Are you saying that you'd like to reconfigure this so that the points are given as (temperature, relative time)? Jul 17, 2017 at 18:24
• yes exactly that what I want to do Jul 17, 2017 at 18:27
• So where exactly do you run into trouble? Do you know how to compute the relative time (i.e. timestamp - startingtimestamp)? Have you tried running the same code after just doing that? i.e., treat the relative timestamps in essentially the same way? Jul 17, 2017 at 18:31
• My problem is on how to treat relative timestamps, how would I compute them Jul 17, 2017 at 18:32

First, find a timestamp corresponding to your "time zero". Let's say that we call it t0. We can define the relative times (denoted timeR here) by

setPoint[x].timeR = setPoint[x].time - t0;


Which we would compute for all of the points. From there, the computation looks pretty much the same:

deltaT = setPoint[y].timeR - setPoint[x].timeR;

t = t + 1/deltaT;

rOut = (1 - t) * setPoint[x].temp + t * setPoint[y].temp;

• what should be setPoint[y].timeR set to ? Jul 17, 2017 at 18:42
• Setpoint[y].timeR is the "relative time", as I computed in the first line. You can either define the relative time as a separate trait of your setPoint object (as I did), or just overwrite the full timestamp with something like setPoint[x].time = setPoint[x].time - t0 Jul 17, 2017 at 18:43
• Thanks so much ! Jul 17, 2017 at 18:46
• how should I set T0, should I set it to time zero 0 ? Jul 18, 2017 at 6:08