I am creating a vector
dt = 0.1;
x = 0:dt:10;
and then trying to find the index for
loc = 4.6;
j = find(x==loc);
the index should be 47, however I receive
j =
1×0 empty double row vector
Matlab is adding a small value (8.8818e-16) to this value and varying small values to other numbers in the vector, but not all. I can remove the small errors on the numbers through
x=round(x,3)
but I'm wondering if there is something that needs to be done to prevent this error in the future. I am currently using version 2018a and 2016b, and they both do this.
Thank you

 채택된 답변

madhan ravi
madhan ravi 2018년 11월 12일
편집: madhan ravi 2018년 11월 12일

0 개 추천

댓글 수: 1

Brandon Graha
Brandon Graha 2018년 11월 12일
Thank you. I guessed it was a problem with floating numbers.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

릴리스

R2018a

질문:

2018년 11월 12일

댓글:

2018년 11월 12일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by