필터 지우기
필터 지우기

"find" function doesn't work

조회 수: 9 (최근 30일)
Yuji Zhang
Yuji Zhang 2011년 10월 4일
Hi~ I got a weird problem here. See the attached picture. "find" works for some values and doesn't for some others. It could a stupid question but can anybody help? Thanks a lot!
So the wavelength vector "lem" has some value but "find" can't find it.
The following is what happens in the command window. It can find the number value but can't find the variable x which equals that value.
>> x
x =
507.0350
>> jj = find(lem==x)
jj =
Empty matrix: 1-by-0
>> jj = find(lem==507.0350)
jj =
3408

채택된 답변

Walter Roberson
Walter Roberson 2011년 10월 4일
find() works fine. Your array does not contain the value in x. If you were to try
lem(3408) - x
you would find that the result is non-zero.
  댓글 수: 6
Yuji Zhang
Yuji Zhang 2011년 10월 4일
actually
jj = find(abs(10000000000*(lem-x))<1)
is a better way. because the error could be >0 or <0.
if it was -1e-14, floor(-1e-14)=-1
Walter Roberson
Walter Roberson 2011년 10월 4일
Please examine the documentation for eps()

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by