root finding and plot of graph

조회 수: 4 (최근 30일)
shiv gaur
shiv gaur 2022년 1월 12일
답변: shiv gaur 2022년 1월 12일
function y=f(x,t3)
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;
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);
y=-(k2)*t2+atan(k1/1i*k2)+atan((k3/k2)*tan(atan(k4/1i*k2)-k3*t3))+m*pi;
end
pl plot the graph between t3 vs x(real) ,t3 vs x(imag)
t3=1e-9:1e-6;
pl pl help to plot

답변 (2개)

Alan Stevens
Alan Stevens 2022년 1월 12일
Are you looking for something like this?
hi = 1e-6; lo = 1e-9;
n = 500;
dt = (hi-lo)/n;
t3 = lo:dt:hi;
y = f(t3);
subplot(2,1,1)
plot(t3,real(y)),grid
xlabel('t3'),ylabel('real part of y')
subplot(2,1,2)
plot(t3,imag(y)),grid
xlabel('t3'),ylabel('imaginary part of y')
function y=f(t3)
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;
k1=k0*sqrt(n1^2-t3.^2);
k2=k0*sqrt(n2^2-t3.^2);
k3=k0*sqrt(n3^2-t3.^2);
k4=k0*sqrt(n4^2-t3.^2);
y=-(k2).*t2+atan(k1./1i.*k2)+atan((k3./k2).*tan(atan(k4./1i.*k2)-k3.*t3))+m*pi;
end
  댓글 수: 1
shiv gaur
shiv gaur 2022년 1월 12일
no first we have to find the value of x ie transcedental equation then plot between t3,x

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


shiv gaur
shiv gaur 2022년 1월 12일
function metal4
%T2 = 1e-9:1e-9:1e-6;
%T3=linspace(1e-9,1e-7,35);
T3=1e-9:1e-8:1e-7;
for j=1:numel(T3)
t3 = T3(j);
p0 = 0.5;
p1 = 1;
p2 = 1.5;
TOL = 10^-2;
N0 = 100; format long
h1 = p1 - p0;
h2 = p2 - p1;
DELTA1 = (f(p1,t3) - f(p0,t3))/h1;
DELTA2 = (f(p2,t3) - f(p1,t3))/h2;
d = (DELTA2 - DELTA1)/(h2 + h1);
i=3;
while i <= N0
b = DELTA2 + h2*d;
D = (b^2 - 4*f(p2,t3)*d)^(1/2);
if abs(b-D) < abs(b+D)
E = b + D;
else
E = b - D;
end
h = -2*f(p2,t3)/E;
p = p2 + h;
if abs(h) < TOL
%disp(p)
break
end
p0 = p1;
p1 = p2;
p2 = p;
h1 = p1 - p0;
h2 = p2 - p1;
DELTA1 = (f(p1,t3) - f(p0,t3))/h1;
DELTA2 = (f(p2,t3) - f(p1,t3))/h2;
d = (DELTA2 - DELTA1)/(h2 + h1);
i=i+1;
end
if i > N0
formatSpec = string('The method failed after N0 iterations,N0= %d ');
fprintf(formatSpec,N0);
end
%P(j)=abs(imag(p)*8.57e5);
P(j)=abs(real(p));
end
plot(T3,P)
end
function y=f(x,t3)
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;
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);
y=-(k2)*t2+atan(k1/1i*k2)+atan((k3/k2)*tan(atan(k4/1i*k2)-k3*t3))+m*pi;
end

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by