Info

此问题已关闭。 请重新打开它进行编辑或回答。

Hello, I am new and trying to plot the imaginary parts of a function, can anyone help?

1 次查看(过去 30 天)
Hello, I am trying to plot the imaginary parts of Kz against Kx from the equation:-
Kz^2 = 8c sin^2(DKx/2)[2c sin^2(DKx/2) - lambdaq0^2]
which i have written as
Kz = sqrt ( 8 .* c .* ( sin ( ( D .* Kx ) ./ 2 ) ) .^2 .* ( 2 .* c .* ( ( sin ( ( D .* Kx) ./ 2 ) ) .^2 ) - ( lambda .* ( q0.^2 ) ) ) )
where lambda, D, q0 and c are all constants.
and really, I have no idea where to start, can anyone help me?

回答(2 个)

Orion
Orion 2014-11-26
Hi,
all the functions you need are here

Chris
Chris 2014-11-26
Hello, thanks for the quick reply. Let us assume that I am completely inept at using matlab and my code looks like this:-
"clear variables
Kx = linspace(0,6*pi,300); D = 2.6 * 10^-9; lambda = 0.5 ; c = 0.5; q0 = 0.01 ;
Kz = sqrt ( 8 .* c .* ( sin ( ( D .* Kx ) ./ 2 ) ) .^2 .* ( 2 .* c .* ( ( sin ( ( D .* Kx) ./ 2 ) ) .^2 ) - ( lambda .* ( q0.^2 ) ) ) );
imag_Kz = imag(Kz);
figure (1) plot (Kx, imag_Kz)"
Does much of this seem wrong?
  1 个评论
Orion
Orion 2014-11-26
Your code is fine.
you really are plotting the imaginary part of Kz against Kx.
Note : when you post some code here, use the button {}Code to format it and make it more readable.

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by