MATLAB: What’s wrong with ‘smooth’ and ‘find’ commands in this code

faq6.1findsmooth

x = [0 0 0 1 1 1 0 1 0 0 1 1 1 0 0 0 0];
y = smooth(x,5);
find(y(:) == 0.6)
ans = Empty matrix: 0-by-1
Running above script gives empty matrix though definitely 0.6 elements exit. What have I done wrong?

Best Answer

Look at result of this line:
y- round(y*10)/10
In vector y there is no exact 0.6 value.
Try this code:
x = [0 0 0 1 1 1 0 1 0 0 1 1 1 0 0 0 0];
y = smooth(x,5);
find(abs(y(:)-0.6)<eps)