Plotting level curves

First set up the complex valued function to plot.

% f = @(z) z.^2;
f = @(z) cosh(z);

Next setup the grid to evaluate the function.

x = linspace(-2,2,401);
y = linspace(-2,2,401);
[xx,yy] = meshgrid(x,y);

Evaluate the function and get the real and imaginary parts.

ff = f(xx+1i*yy);
uu = real(ff);
vv = imag(ff);

Plot the results.

contour(xx,yy,uu,25,'r');
hold on;
contour(xx,yy,vv,25,'b');
hold off;
axis square;
xlabel('Re(z)');
ylabel('Im(z)');