how to i check if matrix cotaining logical 1

4 次查看(过去 30 天)
I got B and i want to check if B cotains at least one '1' display super
if all zeros display not good
How do i do it
A = [1 0 0];
B = logical(A)
if B == 1;
disp('super')
else
disp('not good')
end

采纳的回答

KSSV
KSSV 2020-12-3
编辑:KSSV 2020-12-3
A = [1 0 0];
B = logical(A) ;
if any(B);
disp('super')
else
disp('not good')
end

更多回答(1 个)

Paul Hoffrichter
Paul Hoffrichter 2020-12-3
One simple way:
if sum(B) > 0

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by