Here is a quote from the doc page of eq
function (the functional form of ==
operator):
A == B
If one input is scalar and the other a nonscalar array, then the scalar input is treated as if it were an array having the same dimensions as the nonscalar input array. In other words, if input A is the number 100, and B is a 3-by-5 matrix, then A is treated as if it were a 3-by-5 matrix of elements, each set to 100. MATLAB returns an array of the same dimensions as the nonscalar input array.
And here is the relevant section from the docs of if
statement:
if expression statements end
An evaluated expression is true when the result is nonempty and contains all nonzero elements (logical or real numeric). Otherwise, the expression is false.
So perhaps you meant to use:
if any(data == num)
disp('number found')
end