Effacer les filtres
Effacer les filtres

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

3 vues (au cours des 30 derniers jours)
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.

Réponse acceptée

Cris LaPierre
Cris LaPierre le 8 Jan 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

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by