필터 지우기
필터 지우기

Please help me, how to plot for this function?

조회 수: 1 (최근 30일)
soe min aung
soe min aung 2021년 1월 22일
편집: soe min aung 2021년 1월 22일
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)

채택된 답변

Bram Schroeders
Bram Schroeders 2021년 1월 22일
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');
  댓글 수: 1
soe min aung
soe min aung 2021년 1월 22일
편집: soe min aung 2021년 1월 22일
Thank you so much sir....

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

John D'Errico
John D'Errico 2021년 1월 22일
your function is complex. But a complex variable is really TWO variables, bundled into one. In ths case, it appears the imaginary part of g is virtually constant to within floating point trash.
>> min(imag(g),[],'all')
ans =
5927418.94592444
>> max(imag(g),[],'all')
ans =
5927418.94592444
>> range(imag(g),'all')
ans =
4.65661287307739e-09
But that imaginary part is non zero. So it makes no sense to try to plot a complex variable using surf.
At best, you can plot the real and imaginary parts separately. Since the imaginary part is boring...
surf(K1,K2,real(g))
Well, the real part is also pretty darn boring. Only along one edge of the surface does anything happen.
>> min(real(g),[],'all')
ans =
544051.035191288
>> max(real(g),[],'all')
ans =
544051.035191291
And what did happen was not much. Still down in the least significant bits.
Your function is essentially constant to within an ability to compute it in double precision.

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by