how to use AND operation

조회 수: 2 (최근 30일)
vasantha malairamar
vasantha malairamar 2017년 4월 6일
편집: Mucahid Akyar 2017년 11월 22일
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
vasantha malairamar 2017년 4월 6일
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에서 Numeric Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by