how to use AND operation
Show older comments
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 Comments
KSSV
on 6 Apr 2017
what is the value of eucli ?
vasantha malairamar
on 6 Apr 2017
KSSV
on 6 Apr 2017
eucli = 0.1984 ;
if (eucli<=0.1980) && (eucli>=0.1990)
disp('Happy');
else
disp('unhappy')
end
It is working fine for me without error.
vasantha malairamar
on 6 Apr 2017
KSSV
on 6 Apr 2017
what is your condition actually?
vasantha malairamar
on 6 Apr 2017
Jan
on 7 Apr 2017
(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)
Answers (1)
Andrei Bobrov
on 6 Apr 2017
Edited: Andrei Bobrov
on 6 Apr 2017
Maybe so?
if all(eucli >= 0.1980 & eucli <= 0.1990)
disp('Happy');
else
disp('Sad');
end
3 Comments
vasantha malairamar
on 7 Apr 2017
Andrei Bobrov
on 7 Apr 2017
Accept the answer or not?
Mucahid Akyar
on 22 Nov 2017
Edited: Mucahid Akyar
on 22 Nov 2017
how can we do this on for loop? like for(i = 0: 20 & j = 0: 10) this is possible or not?
Categories
Find more on Data Type Identification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!