Azzera filtri
Azzera filtri

how to i check if matrix cotaining logical 1

4 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

KSSV
KSSV il 3 Dic 2020
Modificato: KSSV il 3 Dic 2020
A = [1 0 0];
B = logical(A) ;
if any(B);
disp('super')
else
disp('not good')
end

Più risposte (1)

Paul Hoffrichter
Paul Hoffrichter il 3 Dic 2020
One simple way:
if sum(B) > 0

Categorie

Scopri di più su Simulation in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by