필터 지우기
필터 지우기

Finding distance between one fixed point and a range of points.

조회 수: 3 (최근 30일)
Prabs
Prabs 2014년 3월 21일
편집: Azzi Abdelmalek 2014년 3월 21일
I have a point, say with coordinates x1,y1. And I have 2 arrays, namely x11 and y11 with the coordinates of the range of points. Want to find the distances between the fixed point and the range of points, and then identify the maximum distance and also plot the line.
Thanks in advance.

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 3월 21일
편집: Azzi Abdelmalek 2014년 3월 21일
%-------------Example----------------------
v=rand(10,2);
n=rand(1,2);
scatter(v(:,1),v(:,2))
hold on
scatter(n(1),n(2),'r')
%--------------------------------------------
[ii,jj]=max(sum(bsxfun(@minus,v,n).^2,2))
m=v(jj,:)
plot([n(1) m(1)],[n(2) m(2)])
hold off

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by