Distance between points of a 3D centreline

조회 수: 1 (최근 30일)
HB
HB 2020년 1월 12일
편집: John D'Errico 2020년 1월 12일
Hello,
I have a curve represented by 3D points (please see attached .mat file). I would like to find out the distance between the 1st point and the 2nd point, the 2nd point and the 3rd point, the 3rd point and the 4th point, the 4th point and the 5th point ect until the final point and the values be saved to a text file.
What would be the simplest most accurate way of achieving this? Any suggestions welcome.
  댓글 수: 1
darova
darova 2020년 1월 12일
What have you tried? Did you try diff function?

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

답변 (1개)

John D'Errico
John D'Errico 2020년 1월 12일
편집: John D'Errico 2020년 1월 12일
Why not try diff? For example, what does
diff(CL,[],1)
do? TRY IT! What is distance? Does that give you something you might be able to work with? Does it get you closer to the goal that you need to achieve?
What if you then squared the elements of that array? Again, THINK! TRY IT!
diff(CL,[],1).^2
Suppose you now used sum on the result?
sum(diff(CL,[],1).^2,2)
what does that represent? Now, again, what is the distance you are trying to achieve? Would a sqrt help here? TRY IT!
When you have a difficult problem, break it into small pieces. Try to move towards the goal you want. Look for functions that will help you to acheive that goal. While it is often unlikely that you will find one magic function that does exactly what you want, it is also the case that very often, you can find several functions that will get you there when taken in combination.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by