Having an array V from 0 to 44.8 in steps of 0.01, I try to use the function find(V == 30) and I get and empty array. Why?
1 回表示 (過去 30 日間)
古いコメントを表示
If I try to look for the index of any other value below 22 I get the correct index, but when I try to look for any value greater than 22 I get a 1*0 empty double row vector. Why is this happening?? Is it a bug?
Following array is being used:
Volt = 0:0.01:44.8
find(Volt == 2) %works perfectly
find(Volt == 20.5) %works as well
find(Volt == 30) %doesn't work even when the value is contained in the array, how do I find the index?
0 件のコメント
回答 (1 件)
Jeremy
2019 年 12 月 5 日
I suspect this is a case of roundoff error. A workaround would be
find(Volt > 29.999 & Volt < 30.001);
Using whatever tolerance you want, it doesn't have to be 1e-3.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!