Interpolation of data using interp1

4 views (last 30 days)
I have a data in CSV file and I am working on a code to plot Time vs Amp., the problem is the data doesn't have a constant interval, sometimes one point is 3 ms from the other, which is 5 ms from the next one, so I used interp1 function to interpolate the data with a difference of 1ms, but I am not sure if it is correct, I've never used this function before, so I would like to know if what I did is correct.
maxtime1 = max(Timeconverted1);
TimestampNum1 = 0:1:maxtime1;
amp1 = interp1(Timeconverted1,ampcorrected1,TimestampNum1);
Timeconverted1 is the original time data (in ms), but with no constant interval. Amp1corrected1 is the amplitude data. I want a variable (amp1) to have values for each second, so I can plot(TimestampNum1, amp1).
Thank you in advance.

Accepted Answer

John D'Errico
John D'Errico on 23 Jul 2015
Yes, if that is what you want to do. This will do a piecewise linear (connect-the-dots) interpolation as you have called it.
Note that if maxtime1 is not an integer, then the last point will NOT be exactly at maxtime1.
  1 Comment
Echo-6
Echo-6 on 13 Sep 2016
Hi John, I got similar task as above question, with data in CSV. The first column doesn't in a constant interval, but strictly increasing. (0-180, Angle of Attack) The second column, well, scatter with values ranging in positive and negative. (-1 to 1, Coefficient of Lift) The third column is same as the second (Coefficient of drag).
What I intend to do is to have this function return the value of the coefficient of tangential force for any angle of attack inputs. The CT, must be calculate from both the data from second and third column. (Same angle of attack)
1) Will interp1 works in this regard? 2) How can I correctly refer to the column for interp1? (A bit confused, since the above question using the text - Not sure if he refer to the entire column?)

Sign in to comment.

More Answers (0)

Categories

Find more on Interpolation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!