why not able to plot size of both same

1 回表示 (過去 30 日間)
shiv gaur
shiv gaur 2022 年 2 月 16 日
回答済み: Image Analyst 2022 年 2 月 16 日
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=2;
t3=linspace(1e-9,1e-6,20)
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 (n<=200)
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
disp(x_new)
plot(t3,real(x_new))
size is same but not able to plot.
  1 件のコメント
shiv gaur
shiv gaur 2022 年 2 月 16 日
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=2;
t3=linspace(1e-9,1e-6,20)
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 (n<=200)
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
disp(x_new)
plot(t3,real(x_new))
edit program

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

採用された回答

Image Analyst
Image Analyst 2022 年 2 月 16 日
Break this up into simpler terms before combining them.
x_new =-(k2).*t2+atan(k1./1i*k2)+atan((k3./k2).*tan(atan(k4./1i*k2)-k3.*t3))+m*pi;
It will help you figure out what the problem is.
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=2;
t3=linspace(1e-9,1e-6,20)
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 (n<=200)
term1 =-(k2) .* t2 + atan(k1 ./ 1i*k2);
term2 = +atan(k3./k2)
term3 = atan(k4./1i*k2) -k3 .* t3;
term4 = tan(term3) + m*pi;
x_new = term1 + term2 .* term4;
% 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
disp(x_new)
plot(t3,real(x_new))
I suspect the problem is in the latter part of term1. What do you want tin the denominator there? Did you forget some parentheses?

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by