Borrar filtros
Borrar filtros

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

3 visualizaciones (últimos 30 días)
Prabs
Prabs el 21 de Mzo. de 2014
Editada: Azzi Abdelmalek el 21 de Mzo. de 2014
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.

Respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 21 de Mzo. de 2014
Editada: Azzi Abdelmalek el 21 de Mzo. de 2014
%-------------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

Categorías

Más información sobre Feature Detection and Extraction en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by