Delete Negative Duplicates from Array
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Sebastian
am 25 Mär. 2024
Kommentiert: Matt J
am 25 Mär. 2024
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 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Catalytic
am 25 Mär. 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 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!