MATLAB Answers

Interpolation of data at each specific value in the variable

5 views (last 30 days)
I have a data set of distance, speed and acceleration and I'm looking for a method to interpolate the data and get a new interpolated variable of distance - speed and another one for distance - acceleration. The issue is that I want the interrpoldation to be exactly at each 1 meter (i.e. 1m, 2m, 3m, 4m ......) also the data is arranged in ascending order but not fixed slope so i can't say interpolate after each 10th value. my question is how can I interpolate the data with respect to distance at each 1 meter in other words how to ask the matlab to interpolate the distance with speed when the distance reached 1 meter and take the distance exactly after or before the first time he reached 1 meter (i.e. in case of having 0.9 - 1.2- 1.5, thus it should take 1.2 and (0.9 or 1.5))

  0 Comments

Sign in to comment.

Accepted Answer

Ameer Hamza
Ameer Hamza on 19 Oct 2020
See interp1(): https://www.mathworks.com/help/matlab/ref/interp1.html. You can probably do something like this
distance; % your distance vecto
speed; % your speed vecto
distanceQ = 1:max(distance); % new distance vector with step size of 1m
speedQ = interp1(distance, speed, distanceQ);

  5 Comments

Show 2 older comments
Abdulkarim Almukdad
Abdulkarim Almukdad on 21 Oct 2020
Thanks Ameer Hamza I have solved this issue by adding the below loop to eliminite the issue of having same numbers
for b=1:length(x)
m(b)=x(b)+ b*1E-10; %add the variable x to m and add 1E-10 to the nubmers
n(b)=y(b)+ b*1E-10; %add the variable y to n and add 1E-10 to the nubmers
end
Abdulkarim Almukdad
Abdulkarim Almukdad on 21 Oct 2020
can you help me with the other question ? I just want a function to make the data from the csv file at 1 column go to the rest of the columns just like the function (text to columns) in excel.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!

Translated by