Define range of values from an array

Dear MatLab comunity,
I got an array (x) of angles ranging from -180 to +180 degrees. I have to define two vectors that include the following values:
Cis = all the values between -90 and 90
Trans = all the values below -90 and above +90
I did the following:
Cis = X((X > -90) & (X < 90));
Trans = (X(X > 90) & X(X < -90));
Problem: the first line (cis) works and the second line (trans) doesn't and gives me an empty set. What's the problem?
Thank you in advance,
Alessandro

 Respuesta aceptada

Walter Roberson
Walter Roberson el 21 de Feb. de 2022
Editada: Walter Roberson el 21 de Feb. de 2022
Trans = X(X > 90 | X < -90);
Question: which one should include exactly -90 or exactly +90 ?

1 comentario

Alessandro Ruda
Alessandro Ruda el 21 de Feb. de 2022
Thank you! That works fine! No one should include the -90 and/or +90 so I think is fine this way.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Productos

Versión

R2020b

Preguntada:

el 21 de Feb. de 2022

Comentada:

el 21 de Feb. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by