Removing row of Matrix under specific condition

11 views (last 30 days)
Hello,
I've a matrix Nx2 which list a pair of coordinates [x,y] like this [x1 y1;x2 y2;x3 y3;....;xn yn]. I would like to removes the rows were one pair is too close from one other.
The idea is I want to compare on pair of coordinates with all others, and if [xi-xj yi-yj] <[cond1 cond2], then I want to supress this row.
I hope I'm clear engouh, Thanks !
  3 Comments
dpb
dpb on 7 Sep 2018
Is it mandatory to use dx, dy as the criterion or would overall d be ok (or what is maybe intended)?
Stephen23
Stephen23 on 7 Sep 2018
Imra's "Answer" moved here:
Hi ! Thanks for asking,
I've a set of coordinate like that : A =[8 10;9 9;9 10;12 12;10 9;13 12;18 24]; For example, I want to keep only those which are separate by at least 2x2 points (To be clear, in practice those coordinate are used to draw a circle, I just dont want to have circle which overlap, so keeping only one).
As often, after posting I had an illumination and did the following thing :
for i=length(A):-1:1
AA=abs(A(i,:)-A(:,:));
AA(i,:)=[];
fact_test=find(AA<2);
if length(fact_test)>1
A(i,:)=[]
end
end
I need to test it a bit before i'm sure it works. (Also, I indeed keep one coordinate between other totally arbitrarely).

Sign in to comment.

Accepted Answer

Matt J
Matt J on 7 Sep 2018
You can use uniquetol(...,'ByRows',1)
  1 Comment
Imra
Imra on 7 Sep 2018
Hi,
I don't manage to use the function correctly, but when I look at the documentation of it, it seems that the loop I posted earlier do more or the less the same thing, with the 'absolute' tolerance.
Thanks for the function, I didn't know it :) !

Sign in to comment.

More Answers (0)

Categories

Find more on Spline Postprocessing in Help Center and File Exchange

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!