how to use AND operation

1 次查看(过去 30 天)
vasantha malairamar
if (eucli<=0.1980) && (eucli>=0.1990) disp('Happy'); end
Operands to the and && operators must be convertible to logical scalar values.
Error in samptest (line 247) if (eucli<=0.1980) && (eucli>=0.1990)
  7 个评论
vasantha malairamar
we have an array of 7 numbers any one of these 7 values ranges between 0.1980 and 0.1990 then it must display happy or else display sad
Jan
Jan 2017-4-7
(eucli<=0.1980) && (eucli>=0.1990)
?? This is mutually exclusive. No number can be smaller than 0.1980 and greater than 0.1990. Either:
(eucli<=0.1980) || (eucli>=0.1990)
or
(eucli>=0.1980) && (eucli<=0.1990)

请先登录,再进行评论。

回答(1 个)

Andrei Bobrov
Andrei Bobrov 2017-4-6
编辑:Andrei Bobrov 2017-4-6
Maybe so?
if all(eucli >= 0.1980 & eucli <= 0.1990)
disp('Happy');
else
disp('Sad');
end
  3 个评论
Andrei Bobrov
Andrei Bobrov 2017-4-7
Accept the answer or not?
Mucahid Akyar
Mucahid Akyar 2017-11-22
编辑:Mucahid Akyar 2017-11-22
how can we do this on for loop? like for(i = 0: 20 & j = 0: 10) this is possible or not?

请先登录,再进行评论。

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by