I need help on a logical vector

1 visualización (últimos 30 días)
Fidele Adanvo
Fidele Adanvo el 14 de Jul. de 2021
Comentada: Devanuj Deka el 14 de Jul. de 2021
Hello,
I hope everyone is okay.
I have a question regarding a logical vector.
let's suppose I have the vector
d=0.1:0.1:0.6;
and I want to obtain a logical vector that meets this condition
N= d==0.4000 & d==0.1000 ;
The result of this operation has to be a vector like this
N=[0 0 0 1 0 1 ] 1x6 logical
Can someone here help me?
Thank you

Respuesta aceptada

Devanuj Deka
Devanuj Deka el 14 de Jul. de 2021
Editada: Devanuj Deka el 14 de Jul. de 2021
You can try this:
ismembertol(d,0.4) | ismembertol(d,0.6)
ismembertol is needed because the '==' logical operator might sometimes not give you the expected results when dealing with fractional data of type 'double'.
  2 comentarios
Fidele Adanvo
Fidele Adanvo el 14 de Jul. de 2021
Thank you
Devanuj Deka
Devanuj Deka el 14 de Jul. de 2021
You're welcome.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by