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.

 Respuesta aceptada

the cyclist
the cyclist el 25 de Ag. de 2014
Editada: the cyclist el 25 de Ag. de 2014

17 votos

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

2 comentarios

Quantopic
Quantopic el 26 de Ag. de 2014
Thanks a lot for help!
Ara Alexandrian
Ara Alexandrian el 10 de Abr. de 2017
if (0<X && X<1)
...also works with multiple conditions.
-Cheers

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 25 de Ag. de 2014

Comentada:

el 10 de Abr. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by