How to delete, in a logical values matrix, rows that contain two or more false values (zero)?
3 次查看(过去 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.
0 个评论
采纳的回答
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!