Delete Negative Duplicates from Array
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sebastian
el 25 de Mzo. de 2024
Comentada: Matt J
el 25 de Mzo. de 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 comentarios
Respuesta aceptada
Más respuestas (1)
Catalytic
el 25 de Mzo. de 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 comentarios
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!