How to delete, in a logical values matrix, rows that contain two or more false values (zero)?

2 visualizaciones (últimos 30 días)
Hello everyone! I explain my problem, trying to be as clear as possible.
I have a matrix, called "faces_logical", whose each row contains a triplet of logical values. For example:
faces_logical = [0 0 0; 0 0 0; 0 0 1; 0 0 0; 1 0 1; 1 1 1; 1 1 1; 1 1 0; 0 0 1; 0 0 1; 0 0 0];
Does exist a function in MATLAB, which allows me to obtain a vector of logical values that returns:
  • "0" for every row containing or [0 0 0] or two zeros (i.e. [0 0 1], [0 1 0], [1 0 0])
  • "1" for every row containing or [1 1 1] or one zero (i.e. [0 1 1], [1 0 1], [1 1 0])?
So, for the written above "faces_logical", the vector shoulds return:
[0 0 0 0 1 1 1 1 0 0 0].
Thank you in advance.

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 8 de En. de 2022
A single function, no, but you can obtain your desired output easily enough.
faces_logical = [0 0 0; 0 0 0; 0 0 1; 0 0 0; 1 0 1; 1 1 1; 1 1 1; 1 1 0; 0 0 1; 0 0 1; 0 0 0];
out = sum(faces_logical,2)>1
out = 11×1 logical array
0 0 0 0 1 1 1 1 0 0

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by