Print an imaginary number:
To print an imaginary number, the function disp will show both parts automatically:
>> disp(z1)
4.0000 + 2.0000i
The function fprintf will print only the real part unless both parts are printed individually:
>> fprintf('%f\n', z1)
4.000000
>> fprintf('%f %f\n', real(z1), imag(z1))
4.000000 2.000000
>> fprintf('%f + %fi\n', real(z1), imag(z1))
4.000000 + 2.000000i