0
$\begingroup$

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;
$\endgroup$
4
  • $\begingroup$ 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)? $\endgroup$ Jul 17, 2017 at 18:24
  • $\begingroup$ yes exactly that what I want to do $\endgroup$ Jul 17, 2017 at 18:27
  • $\begingroup$ 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? $\endgroup$ Jul 17, 2017 at 18:31
  • $\begingroup$ My problem is on how to treat relative timestamps, how would I compute them $\endgroup$ Jul 17, 2017 at 18:32

1 Answer 1

0
$\begingroup$

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;
$\endgroup$
4
  • $\begingroup$ what should be setPoint[y].timeR set to ? $\endgroup$ Jul 17, 2017 at 18:42
  • $\begingroup$ 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 $\endgroup$ Jul 17, 2017 at 18:43
  • $\begingroup$ Thanks so much ! $\endgroup$ Jul 17, 2017 at 18:46
  • $\begingroup$ how should I set T0, should I set it to time zero 0 ? $\endgroup$ Jul 18, 2017 at 6:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .