Take the 2-minute tour ×

I am trying to interpolate data that is given at 20Hz, and I want to interpolate to 25Hz.

while (time.data() && m < (time.size() - 1))
    if (time[m] >= x && time[m] != time[m + 1])
        x0 = time[m];
        x1 = time[m + 1];
        y0 = pos[0][m];
        y1 = pos[0][m + 1];
        y = y0 + (x - x0) * ((y1 - y0)/(x1 - x0));


    x = x + dx;

My problem is that when I increment m, I end up getting to the end of the time vector, but not to the end of the values in time. The "time.data()" at the top is supposed to keep going until the end of the time vector, but the m < (time.size() - 1) is where things get messed up.

Any help would be appreciated.

share|improve this question
may be there are some hardware and its drivers provides such function? –  Brent Jiang Feb 21 '12 at 13:23
I'm reading in the data from a text file. It's based on times that are sampled at about 20Hz, but I need to sample at 25Hz. –  user1187621 Feb 21 '12 at 13:25
take a look here. The first entry seems particularly useful for your task. I'm sorry I can't test it now... –  CapelliC Feb 21 '12 at 13:33
I'm unable to extract the TAR.GZ file under Windows, and I can't install anything to open it since I don't have administrator privilege on my computer (it's a work computer). –  user1187621 Feb 21 '12 at 13:41
I could pass to you the files zipped, I think there is no problem as long as we do this 'privately' –  CapelliC Feb 21 '12 at 16:44
add comment


Your Answer



Browse other questions tagged or ask your own question.