how to make if statement?

2 次查看(过去 30 天)
Latifah
Latifah 2023-2-11
回答: Voss 2023-2-11
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
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 个)

类别

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

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by