how to i check if matrix cotaining logical 1

1 vue (au cours des 30 derniers jours)
Kamil Kacer
Kamil Kacer le 3 Déc 2020
Commenté : Kamil Kacer le 3 Déc 2020
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

Réponse acceptée

KSSV
KSSV le 3 Déc 2020
Modifié(e) : KSSV le 3 Déc 2020
A = [1 0 0];
B = logical(A) ;
if any(B);
disp('super')
else
disp('not good')
end
  1 commentaire
Kamil Kacer
Kamil Kacer le 3 Déc 2020
Thanks dudu just finist my dog detection software whoooo

Connectez-vous pour commenter.

Plus de réponses (1)

Paul Hoffrichter
Paul Hoffrichter le 3 Déc 2020
One simple way:
if sum(B) > 0

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by