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?

1 view (last 30 days)
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

Sign in to comment.

Accepted Answer

Akira Agata
Akira Agata on 4 Feb 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.
M.Prasanna kumar
M.Prasanna kumar on 6 Feb 2019
In your case F is 4*2, out of four coordinates 3 coordinates are satisfying the condition (all possible distances between every coordinate to all other coordintes is greater than 22)
suppose In my case F is 1000*2 (randomly generated ) . out ofthousand how many such possible coordinates will satisfy the condition

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by