I want to have a script that runs if the variable X is within 0 and 1. I writed down the following code:
if 0 < X < 1
statement
else display(NaN)
end
The output script isn't an error but the if condition is not respected and values are away from the interval.
How can I solve this problem. Thanks in advance.

 채택된 답변

the cyclist
the cyclist 2014년 8월 25일
편집: the cyclist 2014년 8월 25일

17 개 추천

You have to write it as two sub-conditions:
if (0<X) && (X<1)

댓글 수: 2

Quantopic
Quantopic 2014년 8월 26일
Thanks a lot for help!
Ara Alexandrian
Ara Alexandrian 2017년 4월 10일
if (0<X && X<1)
...also works with multiple conditions.
-Cheers

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

질문:

2014년 8월 25일

댓글:

2017년 4월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by