# get the distances between points

조회 수: 5(최근 30일)
Alan David 2021년 9월 11일
댓글: Alan David 2021년 9월 16일
Hi,
I have multiple coordinates points which I want to get the minimum distance between point 1 to nearest other point and so on and if the distance not in the range of 55 to 85 exclude that point from cluster. I tried pdist and pdist2 and it gave me the distance from point 1 to others I don't know how to include only the desired distance which is only between 55 to 85
I attached the mat file for the coordinate points
Thanks for helping

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

### 채택된 답변

Akira Agata 2021년 9월 11일
% Calculate distance between each node
D = pdist(xy);
% Convert variable D into square form
Z = squareform(D);
% Extract edges having length of 55~85
idx = Z >= 55 & Z <= 85;
Z(~idx) = 0;
% Convert it into graph object
G = graph(Z);
% Visualize the result
figure
plot(G,'EdgeLabel',G.Edges.Weight) ##### 댓글 수: 5표시숨기기 이전 댓글 수: 4
Alan David 2021년 9월 16일
Thanks Akira,

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

### Community Treasure Hunt

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

Start Hunting!