Removing row of Matrix under specific condition
11 views (last 30 days)
Show older comments
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
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
on 7 Sep 2018
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).
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Spline Postprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!