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 件のコメント

Latifah
Latifah 2023 年 2 月 11 日
is it necessary to separate the two statements for x(6) and x(7)?

サインインしてコメントする。

 採用された回答

Voss
Voss 2023 年 2 月 11 日

0 投票

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB Coder についてさらに検索

製品

リリース

R2021a

タグ

質問済み:

2023 年 2 月 11 日

回答済み:

2023 年 2 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by