Is there any other way to set range in if- else statement?
Show older comments
Hello, please help me with this code.
Why condition is not obeyed? or maybe something's missing?
Code:
m=45
if 0<m<2
disp('blow')
end
Result:
blow
Accepted Answer
More Answers (2)
Adam Danz
on 29 May 2020
Explanation of the error
0<45<2 is the interpretted as (0<45)<2 or, simplifed to 1<2 where 1 is TRUE.
Solution
if 0<m && m<2
1 Comment
Navodita Das
on 30 May 2020
Soundarya Natarajan
on 30 May 2020
if true
% code
end
1 Comment
Soundarya Natarajan
on 30 May 2020
Thanks for support
Categories
Find more on Whos 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!