Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

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

조회 수: 2 (최근 30일)
Chris
Chris 2014년 11월 26일
마감: MATLAB Answer Bot 2021년 8월 20일
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