IF condition with interval

46 ビュー (過去 30 日間)
Quantopic
Quantopic 2014 年 8 月 25 日
コメント済み: Ara Alexandrian 2017 年 4 月 10 日
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 日
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 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by