xnew=1;
k0=2*pi/632;
t3=1000;
t2=2000;
n1=1.512;n2=1.521;n3=4.1-1i*0.211;
n4=1;
m=0;
m=0;
k1=k0*sqrt(n1^2-xnew^2);
k2=k0*sqrt(n2^2-xnew^2);
k3=k0*sqrt(n3^2-xnew^2);
k4=k0*sqrt(n4^2-xnew^2);
n=1;
while d>0.0001 & n< 1000
n=n+1;
xold=xnew
k1=k0*sqrt(n1^2-xnew^2);
k2=k0*sqrt(n2^2-xnew^2);
k3=k0*sqrt(n3^2-xnew^2);
k4=k0*sqrt(n4^2-xnew^2);
y=(k2)*t2-atan(k1/1i*k2)-atan((k3/k2)*tan(atan(k4/1i*k2)-k3*t3))+m*pi;
d=abs(xnew-xold);
end
disp([n,xnew,xold])
pl show the value by varying the t3 1 t0 1000
plot(t3,xnew)

댓글 수: 6

Torsten
Torsten 2022년 2월 26일
You never update x.
So xold = xnew already in the first step, d=0 and MATLAB consequently exits the while loop.
What do you want to make converge in the above code ?
shiv gaur
shiv gaur 2022년 2월 26일
we want to find root of the equation at which y=0 again by varying the value of t3 the root vary so plot t3 vs xnew
Torsten
Torsten 2022년 2월 26일
편집: Torsten 2022년 2월 26일
Then you have to update x according to Newton's method:
xnew = xold - y(xold)/y'(xold)
shiv gaur
shiv gaur 2022년 2월 26일
difficult for derivative of equation
Torsten
Torsten 2022년 2월 26일
Why don't you use fsolve to solve
real(y) = 0 and imag(y) = 0 for
real(x) and imag(x) ?
Don't you have a licence for the optimization toolbox ?
shiv gaur
shiv gaur 2022년 2월 26일
pl edit the program

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

제품

릴리스

R2021b

태그

질문:

2022년 2월 26일

댓글:

2022년 2월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by