Relational Operator doesn't work

1 visualización (últimos 30 días)
Esteban
Esteban el 23 de Mayo de 2013
After a simulation I want to determine the limits of the axes using the relational operator ==. For example:
refTime = 0:2e-3:1.5;
t0 = 0.8;
find(refTime == t0)
this returns:
ans =
Empty matrix: 1-by-0
If I try the following in the same instance:
x = 0:10
find(x == 5)
It works and returns
ans = 6.
What could be wrong??

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 23 de Mayo de 2013
Editada: Azzi Abdelmalek el 23 de Mayo de 2013
Try
refTime = 0:2e-3:1.5;
t0 = 0.8;
tolerence=1e-5
find(abs(refTime-t0)<tolerence)
  2 comentarios
Esteban
Esteban el 23 de Mayo de 2013
Thanks, this works :-) But I still don't see why my approach doesn't work. By visual inspection of refTime in the workspace I can see that it has an element with value exactly equal to t0.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by