How to find distance around point

조회 수: 1 (최근 30일)
Po Penya
Po Penya 2019년 5월 25일
답변: KSSV 2019년 5월 26일
I have 5 centroids point. and I want to compare about each point
Ex
pointA = [109,380]
pointB = [162,471]
pointC = [201,536]
pointD = [470,143]
pointE = [575,391]
compare distance between pointA and pointB, pointB and pointC, pointC and pointD, pointD and pointE, pointE and pointA
then calculate mean for pointA -->E
Ex pointA
x-axis |575-109| = 466
y-axis |391-380| = 11
x-axis |109-162|= 53
y-axis |380-471| = 91
x-axis mean y-axis mean
466+53 = 519 11+91 = 102
519/2 = 259.5 102/2 = 51
mean x y
259.5+51 = 310.5
310.5/2 = 155.25
and make it finish all point.
then delete point those min mean value.
  댓글 수: 1
dpb
dpb 2019년 5월 25일
First, do NOT build variables with successive letter identifiers--use an array instead (you see in the above why not; there's no convenient way to address the various variables except by writing explicit code for every case).
Then see
doc pdist % Statistics TB

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

답변 (1개)

KSSV
KSSV 2019년 5월 26일
points = [109,380 ;
162,471 ;
201,536 ;
470,143 ;
575,391] ;
%
coor = [points ; points(1,:)] ;
d = sqrt(sum(diff(coor).^2,2))

Community Treasure Hunt

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

Start Hunting!

Translated by