필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
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.

채택된 답변

Cris LaPierre
Cris LaPierre 2022년 1월 8일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by