function quadrant(z)
% Learn how to use "if-elseif-else".
% judge the quadrant in which a complex number lies

% Example: quadrant( -2+3*j )   % z in Cartesian form
%          quadrant( 10.8*exp(j*sqrt(3)) )   % z in polar form

Re = real(z);
Im = imag(z);
if Im == 0
    disp('This number is real.');
elseif Re == 0
    disp('This number is imaginary.');
elseif Re > 0 && Im > 0
    disp('This number lies in the first quadrant.');
elseif Re < 0 && Im > 0
    disp('This number lies in the second quadrant.');
elseif Re < 0 && Im < 0
    disp('This number lies in the third quadrant.');
else              % the case that Re > 0 && Im < 0
    disp('This number lies in the fourth quadrant.');
end
