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

조회 수: 3 (최근 30일)
J AI
J AI 2021년 5월 18일
편집: J AI 2021년 5월 18일
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