필터 지우기
필터 지우기

How to find the length of a curve from a list of points using different length scales?

조회 수: 25 (최근 30일)
I want to find the length of a curve from a list of points using different length scales. The smaller the length scale, the more accurate is the result. I want to show this thing by writing a code. Starting from the sine curve will be enough.
x=(0:1:360)*pi/180;
y=sin(x);
plot(x,y);

채택된 답변

Matt J
Matt J 2020년 9월 20일
curveLength = sum(vecnorm( diff( [x(:),y(:)] ) ,2,2))
  댓글 수: 3

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Tamas Rozsa
Tamas Rozsa 2023년 1월 29일
편집: Tamas Rozsa 2023년 1월 30일
Based on https://www.mathworks.com/matlabcentral/answers/1787410-how-can-i-calculate-the-length-of-curve, you may also calculate a more detailed (and in some cases more accurate) result, by utilizing gradient() instead of diff(), and/or cumsum() instead of sum(), depending on your exact use-case:
dX = gradient(X);
dY = gradient(Y);
% option 1
Len = cumsum(hypot(dX,dY)) % if sublengths of all segments also needed
% option 2
Len = sum(hypot(dX,dY)) % if only total length needed

카테고리

Help CenterFile Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by