I have matrix F (x,y coordinates), which is 1000*2 matrix. i calculated distances between coordinates using PDIST2 command. i want coordinates which are at distance greater than 22?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
M.Prasanna kumar
el 4 de Feb. de 2019
Comentada: M.Prasanna kumar
el 6 de Feb. de 2019
F = [x5;y5]'; % x,y coordinates
distances = pdist2(F,F); %% claculating distances between every coordinate to all other coodinates
closepoints = distances > 22; %% checking the condition
result = find(closepoints==1); %%
based on the logical condition how to get the coordinates (x,y) which are grater than 22
4 comentarios
madhan ravi
el 4 de Feb. de 2019
So you want to obtain the x and y coordinates when distance is greater than 22 ?
Respuesta aceptada
Akira Agata
el 4 de Feb. de 2019
One possible solution would be like this:
F = [x5;y5]'; % x,y coordinates
D = pdist(F); % pdist function is suitable in this case
idx = squareform(D) > 22;
[p1,p2] = find(triu(idx));
Then, F(p1(i),:) and F(p2(i),:) (for i = 1, ..., numel(p1)) will give the coordinates (x1,y1) and (x2,y2) whose distance are grater than 22.
7 comentarios
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!