problem in plot while loop
Mostrar comentarios más antiguos
k0=(2*pi/0.6328)*1e6;
t2=1.5e-6;
n1=1.512;n2=1.521;n3=4.1-1i*0.211;
n4=1;
m=0;
x=1.512;
t3=1e-9:1e-6;
k1=k0*sqrt(n1^2-x^2);
k2=k0*sqrt(n2^2-x^2);
k3=k0*sqrt(n3^2-x^2);
k4=k0*sqrt(n4^2-x^2);
tol = 1e-12;
n = 1;
while 1
x_new =-(k2)*t2+atan(k1/1i*k2)+atan((k3/k2)*tan(atan(k4/1i*k2)-k3*t3))+m*pi;
if abs(x_new-x) < tol, break; end
x =x_new;
k1=k0*sqrt(n1^2-x^2);
k2=k0*sqrt(n2^2-x^2);
k3=k0*sqrt(n3^2-x^2);
k4=k0*sqrt(n4^2-x^2);
n=n+1;
end
pl plot graph between t3 vs x_new
where x_new is the root of the equation
8 comentarios
Sajid Afaque
el 16 de Feb. de 2022
Editada: Sajid Afaque
el 16 de Feb. de 2022
can u explain your problem in little detail
and i think equation in line number 18 needs to be cross checked
x_new =-(k2)*t2+atan(k1/%i*k2)+atan((k3/k2)*tan(atan(k4/%i*k2)-k3*t3))+m*pi;
Note : always update your code under code section
shiv gaur
el 16 de Feb. de 2022
KSSV
el 16 de Feb. de 2022
@shiv gaur If code is correct why you are unable to plot?
shiv gaur
el 16 de Feb. de 2022
You code does not conatin any command for plotting. Why do you expect, that there is a graphical output?
What is the purpose of:
t3=1e-9:1e-6
This is 1e-9, so t3 is a constant.
shiv gaur
el 16 de Feb. de 2022
Walter Roberson
el 16 de Feb. de 2022
What do the % mean in your formula for x_new?
shiv gaur
el 16 de Feb. de 2022
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!