MATLAB: Find function cannot find the value

comparing floating point numbersfind

Hello, I'm trying to use find function to find the value for example from a data with: data = [0, 1.00 2.00 3.00 4.00]; float values for example, if I do:
[~,indx] = find(data == 1.00),
the result would be an empty cell, []. Why is this the problem?

Best Answer

It works fine:
data = [0, 1.00 2.00 3.00 4.00];
[~,indx] = find(data == 1.00)
In the command window:
indx =
2
I suspect your numbers aren't EXACTLY that and what you're running into is this: http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F