Delete Negative Duplicates from Array
2 views (last 30 days)
Show older comments
I have a 3-by-n array of points representing the vertices of a polyhedron. I need to identify all the axes that pass through the origin and a vertex, so I need to identify and remove all the points x where -x also exists in the array. I can manage this by iterating through every point and finding negatives, but it feels like there should exist a sneaky way to use the unique function to do the same thing but better.
Thanks in advance!
0 Comments
Accepted Answer
More Answers (1)
Catalytic
on 25 Mar 2024
X=rand(3,4); X=[X,-X(:,1)]
[~,~,G]=unique([X,-X]','rows');;
[N,~,bin]=histcounts(G,1:max(G)+1);
bin=bin(1:end/2);
X(:,N(bin)>1)=[]
0 Comments
See Also
Categories
Find more on Logical 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!