'find' returning empty vector
조회 수: 26 (최근 30일)
이전 댓글 표시
I've written this section of code:
for k=0.05:0.05:38
index=find(A(:,2)==k);
c=max(A(index,1));
end
but for k=37.7, it returns index as a 0x1 empty double column vector. For all other values of k it works. However, when I simply do:
index=find(A(:,2)==37.7);
it returns a number. Any ideas why the loop won't? Thanks
댓글 수: 1
Stephen23
2022년 6월 14일
"Any ideas why the loop won't?"
For more discussions on this topic:
This is worth reading as well:
채택된 답변
KSSV
2022년 6월 14일
tol = 10^-3 ;
index=find(abs(A(:,2)-37.7)<tol);
Read about comparing floating point numbers.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!