how to make if statement?

12 vues (au cours des 30 derniers jours)
Latifah
Latifah le 11 Fév 2023
Réponse apportée : Voss le 11 Fév 2023
i want to make x(6) and x(7) condition with if , and it's look wrong, can you help me to fix it
H=0;
if (x(6)>0,x(7)>0)
H = 1;
  1 commentaire
Latifah
Latifah le 11 Fév 2023
is it necessary to separate the two statements for x(6) and x(7)?

Connectez-vous pour commenter.

Réponse acceptée

Voss
Voss le 11 Fév 2023
If you want H to be 1 when x(6)>0 and x(7)>0, then:
H=0;
if x(6)>0 && x(7)>0
H = 1;
end
If you want H to be 1 when x(6)>0 or x(7)>0, then:
H=0;
if x(6)>0 || x(7)>0
H = 1;
end

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB Coder dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by