How to find the length of a curve from a list of points using different length scales?
30 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mustafa Rifat
el 20 de Sept. de 2020
Editada: Tamas Rozsa
el 30 de En. de 2023
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);
0 comentarios
Respuesta aceptada
Más respuestas (1)
Tamas Rozsa
el 29 de En. de 2023
Editada: Tamas Rozsa
el 30 de En. de 2023
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
0 comentarios
Ver también
Categorías
Más información sobre Curve Fitting Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!