MATLAB: Please help me, how to plot for this function

3d

k1 = 0:100;
k2 = linspace(50,150,101);
[K1,K2] = meshgrid(k1,k2);
g = (1./(1-(((50*K1)/pi)^2))).*((50./pi)^2)*1i*K1*(1-exp(-1i*100*K1))...
*(1./(1-(((100*K2)/pi)^2))).*((100./pi)^2)*1i*K2*(exp(-1i*150*K2)+exp(-1i*50*K2));
surf(K1,K2,g)

Best Answer

Because complex doubles contain two dimensions, it is not possible to plot a complex plane this way. You can either plot the real part, the imaginary part or the norm of the individual components in a surf-plot. You can create and plot these components like this:
k1 = 0:100;
k2 = linspace(50,150,101);
[K1,K2] = meshgrid(k1,k2);
g = (1./(1-(((50*K1)/pi)^2))).*((50./pi)^2)*1i*K1*(1-exp(-1i*100*K1))...
*(1./(1-(((100*K2)/pi)^2))).*((100./pi)^2)*1i*K2*(exp(-1i*150*K2)+exp(-1i*50*K2));
g_real = real(g);
g_imag = imag(g);
g_norm = zeros(size(g));
for i = 1:size(g,1)
for j = 1:size(g,2)
g_norm(i,j) = norm(g(i,j));
end
end
subplot(1,3,1)
surf(K1,K2,g_real)
title('real part of g');
subplot(1,3,2)
surf(K1,K2,g_imag)
title('imaginary part of g');
subplot(1,3,3)
surf(K1,K2,g_norm)
title('norm of individual components of g');