find is not matching a value of 1 in an array
1 回表示 (過去 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)]
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/278214/image.jpeg)
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!