Having an array V from 0 to 44.8 in steps of 0.01, I try to use the function find(V == 30) and I get and empty array. Why?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
If I try to look for the index of any other value below 22 I get the correct index, but when I try to look for any value greater than 22 I get a 1*0 empty double row vector. Why is this happening?? Is it a bug?
Following array is being used:
Volt = 0:0.01:44.8
find(Volt == 2) %works perfectly
find(Volt == 20.5) %works as well
find(Volt == 30) %doesn't work even when the value is contained in the array, how do I find the index?
0 comentarios
Respuestas (1)
Jeremy
el 5 de Dic. de 2019
I suspect this is a case of roundoff error. A workaround would be
find(Volt > 29.999 & Volt < 30.001);
Using whatever tolerance you want, it doesn't have to be 1e-3.
0 comentarios
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices 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!