calculate the length of scattered data

3 views (last 30 days)
yunwei hu
yunwei hu on 10 Feb 2020
Commented: KSSV on 10 Feb 2020
Hello everyone,
contour.jpg
can anyone tell me how to calculate the length of the curve l plotted here?
thanks in advance!

Accepted Answer

KSSV
KSSV on 10 Feb 2020
Edited: KSSV on 10 Feb 2020
Let A be your n*2 data points
A = [A ; A(1,:)] ;
x = A(:,1) ; % x coordinates of the points
y = A(:,2) ; % y coordinates of the points
iwant = sum(sqrt(diff(x).^2+diff(y).^2)) ; % distance formula
  4 Comments
yunwei hu
yunwei hu on 10 Feb 2020
Sorry l did not explain clearly before.
Actually this is the contour of a cell and i would need the length of it. That is why the curve is closed.
KSSV
KSSV on 10 Feb 2020
If plot(x,y), give you the above curve..you can use what I have given.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!