# Minimum distance between two Irregular forms

조회 수: 3 (최근 30일)
mohammed alany 2019년 3월 31일
댓글: mohammed alany 2019년 4월 1일
WHAT is the min distance between these two shapes?
note: i know the connecting points of big figure.

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

### 채택된 답변

Image Analyst 2019년 3월 31일
편집: Image Analyst 2019년 4월 1일
If you have the stats toolbox, try this:
distances = pdist2(xyShape1, xyShape2)
minDistance = min(distances(:))
[minRows, minColumns] = find(distances == minDistance)
##### 댓글 수: 18이전 댓글 16개 표시이전 댓글 16개 숨기기
Walter Roberson 2019년 4월 1일
[minDistance, minColumns] = min(distances);
Note: you might need min(distances,2) depending on whether you need the minimum distance from each point in the first to any point in the second, or the minimum distance from each point in the second to any point in the first.
When you do a single min() call and the try to use find(), then that could be appropriate for the case where one point might happen to be exactly the same minimum distance to two more or points in the other shape, and you need to know all of them. In a situation such as that, you would generally get a different number of minimum points for each, which is a bit tricky to represent in a rectangular numeric matrix. Is this the situation that applies for you, that you need to know all of the points that are the same minimum distance? If so then typically a loop would be easiest.
mohammed alany 2019년 4월 1일
many thanks, now it's work correctly.

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

### 카테고리

Help CenterFile Exchange에서 Dimensionality Reduction and Feature Extraction에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by