find is not matching a value of 1 in an array
2 次查看(过去 30 天)
显示 更早的评论
I am unable to match a value of 1 with find when checking an array produced by linspace. Is this as expected behavior?
% Create our k samples.
k = linspace(0.1, 2.0, 20)
% Find indexes.
[find(k==0.5) find(k==1.0) find(k==1.5)]

0 个评论
采纳的回答
更多回答(1 个)
Loren Shure
2020-3-19
You are running into an issue of floating point arithmetic. You might use ismembertol : mathworks.com/help/matlab/ref/ismembertol.html
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!