MATLAB: Dont want the number if its a part of a complex number

complex numbersimaginary numbersreal part of a complex number

So I know that doing;
Z = [0.5i 1+3i -2.2];
X = real(Z)
would give me
X = 0 1.0000 -2.2000
but what should I do if I only want pure real numbers and not even the real part of the complex number?
for example;
Z = [0.5i 1+3i -2.2];
"…"
would give me
X = 0 0 -2.2000
Thanks any help is appreciated.

Best Answer

Z = [0.5 1+3i -2.2];
Z(~imag(Z))