Matlab Logical Inequality with Tripple condition

Hi all,
I would like to determine a logical inequality, but with three conditions imposed. For example, in the case of two conditions the logical inequality would be:
idx = Condition1 < Vector_to_Compare & Vector_to_Compare < Condition2 ;
In the case where I have three vectors I cant write something like
idx = Condition1 < Vector_to_Compare & Vector_to_Compare < Condition2 & Vector_to_Compare < Condition3 ;
What would I do in order to impose the three vector condition to the logical index ?
I know it seems that I could possibly combine Condition2 and Condition3, however the one comes from a completely different vector than the other i.e. its completely different in 'nature'.

4 comentarios

James Tursa
James Tursa el 18 de Sept. de 2017
Your three vector condition works fine as is with double class variables. What specific problems are you encountering? What do you mean by different in 'nature'?
You mean this?
idx = Condition1 < V1 & V1 < Condition2 & V2 < Condition3
where V1 and V2 are different vectors but with the same size? Looks right the way it is...
Cam Salzberger
Cam Salzberger el 18 de Sept. de 2017
Donald, I guess the issue is that V2 doesn't have the same size as V1. So in that case the "&" will fail, unless one of them is a scalar.
Konstantinos, what exactly are you hoping to get out of this? If your vectors are different sizes, having a logical indexing vector doesn't really make sense in that context. Can you give us more context on what you have and what you'd like? With an example?
Walter Roberson
Walter Roberson el 18 de Sept. de 2017
Not sure why you are not using and()?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Preguntada:

el 18 de Sept. de 2017

Comentada:

el 18 de Sept. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by