z = [1 1+2*i 3 4+5*i]
mask = imag(z)==0;
The variable mask is a logical variable that is TRUE at the locations of the numbers that do not have an imaginary component, and FALSE otherwise.
You'll need to be careful if you have imaginary parts that are within floating-point precision of zero. You might need to use a tolerance, rather than strict equality.