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);
Sudipta Ray
2016년 1월 21일
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!