Violation of logical indexing criteria problem
显示 更早的评论
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 个评论
Stephen23
2016-1-21
You should read about the precision limits of floating point values:
And some external links on this topic:
采纳的回答
更多回答(2 个)
Image Analyst
2016-1-20
If you want =, then use =
indexesInRange = abs(x) <= 0.5;
alpha = x(indexesInRange);
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!