Violation of logical indexing criteria problem
Mostrar comentarios más antiguos
Hi everyone. I am collecting grid points (alpha) from a larger grid (x) by the following commands:
I = abs(x)<0.5;
alpha = x(I);
My problem is that this criteria is not being able to filter x = -0.5. My question is, does Matlab think abs(-0.5)>0.5?
What am i doing wrong here? Please help.
1 comentario
Stephen23
el 21 de En. de 2016
You should read about the precision limits of floating point values:
And some external links on this topic:
Respuesta aceptada
Más respuestas (2)
Image Analyst
el 20 de En. de 2016
If you want =, then use =
indexesInRange = abs(x) <= 0.5;
alpha = x(indexesInRange);
1 comentario
Sudipta Ray
el 21 de En. de 2016
Sudipta Ray
el 21 de En. de 2016
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!