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

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

回答(1 个)

J AI
J AI 2021-5-18
编辑:J AI 2021-5-18
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!

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by