OrangeRind
OrangeRind

Reputation: 4818

Matlab interpolation to switch dependent variable

I have an Nx2 matrix with columns as 'Time' and 'Progress'.

Progress is integral and Time is a real value corresponding to each progress unit.

I want to reverse the dependency and make 'Time' integral and output the fractional 'Progress' at every unit time step.

How can this be done?

Upvotes: 0

Views: 208

Answers (1)

Ramashalanka
Ramashalanka

Reputation: 8864

Use interp1(Progress,Time,TimesWanted) where TimesWanted is a new vector with the times that you want. For example:

Progress=1:10;       %just a guess of the sort of progress you might have
Time=Progress*5.5;   %the resulting times (say 5.5s per step)
TimesWanted=10:5:50; %the times we want
interp1(Time,Progress,TimesWanted)

gives me:

ans =
1.8182    2.7273    3.6364    4.5455    5.4545    6.3636    7.2727    8.1818    9.0909

which is the progress at TimesWanted obtained by interpolation.

Upvotes: 3

Related Questions