MATLAB: Interpolation of data using interp1

interp1interpolationplot

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.

Best Answer

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.
Related Question