"find" function doesn't work

12 次查看(过去 30 天)
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