Clear Filters
Clear Filters

Resampling of xy-coordinates based on cumulative length (NOT time)

3 views (last 30 days)
The cumulative lengths for a set of x1 and y1 coordinates ("waypointsOriginal" in the mat file attached) can be obtained using the function (function file attached as well):
[cumLengthWP,~,~] = CalcCurvature(waypointsOriginal(:,1:2));
However, I was wondering, for a vector cumLength (also can be found in the mat file) which has a different dimension, is there a way to find the corresponding x2 and y2 coordinates such that when I do
plot(x1,y1,'r',x2,y2,'b')
the two plots will be identical?
Thank you in advance for your effort and time. I will be glad to clarify any confusion regarding the question.
FYI: I am not looking for time resampling foor which I know we can use the resample command.

Answers (1)

J AI
J AI on 18 May 2021
Edited: J AI on 18 May 2021
I have found a workaround for this which works for my particular application. I have basically used the polyfit function:
load('waypointsData.mat')
px = polyfit(cumLengthWP,waypointsOriginal(:,1),3); % using 3rd order polynomial
py = polyfit(cumLengthWP,waypointsOriginal(:,2),3); % using 3rd order polynomial
for i = 1:length(cumLength)
waypoints_resampled(i,1) = px(1)*cumLength(i)^3 + px(2)*cumLength(i)^2 + px(3)*cumLength(i) + px(4); % x2
waypoints_resampled(i,2) = py(1)*cumLength(i)^3 + py(2)*cumLength(i)^2 + py(3)*cumLength(i) + py(4); % y2
end
plot(waypoints_resampled(:,1),waypoints_resampled(:,2),'r',waypointsOriginal(:,1),waypointsOriginal(:,2),'b--')
legend('Resampled','Original')
I definitely look forward to hearing more efficient way(s). Thanks again!

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!