double conditional in one line
Mostrar comentarios más antiguos
By chance I tried a sentence like
0<x<1
i cannot find any documentation for this.
At the beginnnig looks like weird
>> x=0.23: 0<x<1
ans =
logical
0
but
>> x=0.23: 0.1<x<1.1
ans =
logical
1
You can concatenate more, exemple
>> x=1; y=2; 0<x<y<2
ans =
logical
1
I still cannot figure out how it really works. Any help?
Respuesta aceptada
Más respuestas (2)
You need to be using '&'
x=0.23;
0<x & x<1
You have to join the multiple conditions with a logical operator. For example, the condition 0<x<1 is written like this
x=0.23;
0<x && x<1
and this one 0<x<y<2 is written like this
x=1;
y=2;
0<x && x<y && y<2
2 comentarios
Antonio Baeza
el 5 de Jun. de 2023
Les Beckham
el 5 de Jun. de 2023
You are quite welcome.
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!