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

37 ビュー (過去 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 件のコメント
Matt J
Matt J 2022 年 1 月 19 日
If so, please Accept-click the answer.

サインインしてコメントする。

その他の回答 (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 Center および File ExchangeCurve Fitting Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by