% code by Colin Macdonald, comments by Ben % this shows the contour lines of cos(z) figure(1); xx = -pi:.01:pi; yy = -3:.01:3; [xg,yg] = meshgrid(xx,yy); Z = xg+1i*yg; %trick for commenting out a whole paragraph of code % remove the if statement if you want to see what % the real and imaginary components look like individually if ( 1==0) figure(1); clf; pcolor(xg,yg,real(cos(Z))); shading flat; hold on; [C,H] = contour(xg,yg,real(cos(Z)),[0 0],'k-'); %for j=1:length(H); % set(H(i),'color', colorbar figure(2); clf; pcolor(xg,yg,imag(cos(Z))); shading flat; hold on; contour(xg,yg,imag(cos(Z)),[0 0], 'k-'); colorbar end figure(3); clf; pcolor(xg,yg,real(cos(Z))); shading flat hold on; [C,H] = contour(xg,yg,imag(cos(Z)),[0 0], 'k--'); for i=1:length(H) set(H(i),'linewidth',3); end hold on; contour(xg,yg,real(cos(Z)), [1,1.1,1.2,1.5], 'k-' ); colorbar;