Interpolation of data using interp1

1 次查看(过去 30 天)
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.

采纳的回答

John D'Errico
John D'Errico 2015-7-23
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 个评论
Echo-6
Echo-6 2016-9-13
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?)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by