Finding the nearest node in this case
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sushree Patra
el 9 de Dic. de 2018
Comentada: Sushree Patra
el 9 de Dic. de 2018
I am trying to find nearest node from the fixed node.
so here is the code
x1= [16,38,56,78,45];
y1 =[23,62,77,56,34];
x2 = 100*rand(20,1);
x2= 150*rand(20,1);
for i = 1:5
text(x1(i),y1(i),num2str(i))
end
for i= 1:20
text(x2(i), y2(i),num2str(i));
end
Now i have to find out the nearest node of [x1,y1] w.r.t [x2,y2]
Objective find out which 10nodes from [x2,y2] are near to the [x1,y1] node
0 comentarios
Respuesta aceptada
Walter Roberson
el 9 de Dic. de 2018
pdist2
6 comentarios
Walter Roberson
el 9 de Dic. de 2018
dd = pdist2([x1 y1], [x2 y2]);
[~, idx] = min(dd);
xclosest = x2(idx);
yclosest = y2(idx);
... I feel like I just did someone's homework for them because they did not read the documentation .
Más respuestas (0)
Ver también
Categorías
Más información sobre Statistics and Machine Learning Toolbox 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!