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.
  1 件のコメント
soe min aung
soe min aung 2021 年 1 月 22 日
thank you so much sir...

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Type Identification についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by