In MATLAB R2016a, suppose that I define the array arr = -0.2:0.1:0.2. I may then find the location of the value el = 0.1 with the command idx = find(arr==el). This correctly yields idx = 4.
But now suppose that I define a larger array such as arr = -0.3:0.1:0.3. If I again try to find the location of the value el = 0.1 with the command idx = find(arr==el), I obtain an empty matrix. For some reason, MATLAB does not consider the 0.1-like element in arr to be equal to el = 0.1.
Why is this and how can I generate an array for which element-finding operations like the above work reliably?
ismembertolto solve your problem, like this:find(ismembertol(-0.3:.1:.3, 0.1))ismembertolas an answer to the duplicate since it's not currently listed.