Info

This question is closed. Reopen it to edit or answer.

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

1 view (last 30 days)
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?

Answers (2)

Orion
Orion on 26 Nov 2014
Hi,
all the functions you need are here

Chris
Chris on 26 Nov 2014
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 Comment
Orion
Orion on 26 Nov 2014
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!