0

I have some travel time data stored as column vectors. I want to write a script that will allow me run a linear interpolation from specified initial and final values, to make a column of distances, so I can calculate velocity.

example: Column 1: t1,t2,t3......tn; Column 2: (using the linear interpolation we create) d1, d2, d3....dn

So here we have generated a distance for each travel time based on an initial distance and a final distance.

then it should be simple to generate a new column that is simply the interpolated distances / travel times. Thanks for your help. Cheers

M Vaughan
  • 5
  • 4

1 Answers1

0

interp1 is your friend here:

% from zero to one hour
measuredTime = [0 1];

% from 0 to 100 km
measuredDistance = [0 100];

% 10 minute intervals
intermediateTimes = measuredTime(1):10/60:measuredTime(end);

% interpolated distances
intermediateDistances = interp1(measuredTime,measuredDistance,intermediateTimes);
onewhaleid
  • 355
  • 9
  • 18
  • How can this be modified to read a column of existing arrival time data and create a distance value for each value in the existing column? Cheers – M Vaughan Feb 24 '15 at 01:52
  • 2
    Without seeing your data it's hard to answer your specific question. This page should get you started: http://en.wikibooks.org/wiki/MATLAB_Programming/Arrays/Basic_vector_operations – onewhaleid Feb 24 '15 at 01:58
  • I have one column with some numbers in it. I need to make another column next to it that contains some interpolated values. the values need to increase linearly between two numbers that I can set as the start and finish for the interpolation. – M Vaughan Feb 24 '15 at 02:15
  • @MVaughan Please update the question with the relevant information rather than making comments. – kkuilla Feb 24 '15 at 09:03