Error indexing usig logicals
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
Hi there, I have an issue while using logicals for change the size of a vector: here's a simple code test:
rad = 0.3;
A = linspace(0,1,51);
nn = A(A <= 3*rad);
n2 = A(A <= 0.9);
Normally size(nn) has to be equal to size(n2), but nope... I'm kind of lost. Does anyone have an idea what's going on here?
댓글 수: 1
"Error indexing usig logicals"
There is no error.
" Does anyone have an idea what's going on here?"
Yes. It is very simple: you need to learn about the practical limits of floating point numbers:
And some external links on this topic:
답변 (1개)
Fangjun Jiang
2018년 5월 17일
0 개 추천
This is really a floating point data precision issue. Run this to find out and deal with it based on whatever your use case.
isequal(3*0.3, 0.9)
댓글 수: 0
이 질문은 마감되었습니다.
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!