I've a vector with 20000 elements. taux1=[0.01 0.02 ... 200]. If I type p=find(taux1==0.02), it returns p=2. Ok! If I type max(taux1), it returns ans=200.0000. Ok! But, if p=find(taux1==200), the answer is p=Empty matrix: 1-by-0. Others "round" values have shown the same answer, even if the entry have consider decimals (for example, taux1==200.0000). However, if I type p=find(taux1==max(taux1)), it returns p=20000. What may be happening? Thanks!

 채택된 답변

Walter Roberson
Walter Roberson 2016년 9월 29일

0 개 추천

Floating point roundoff. Those values only look like they are integers.

댓글 수: 3

Alexandre Lopes
Alexandre Lopes 2016년 9월 29일
Thank you, Walter. Do you suggest any modification in my "find" command? I tried the "areEssentiallyEqual...", but it didn't work within this command...
Walter Roberson
Walter Roberson 2016년 9월 29일
You can use ismembertol() . The first output is a logical vector; the second output is indices.
Alexandre Lopes
Alexandre Lopes 2016년 10월 1일
Thanks!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by