run the program in matlab

1 view (last 30 days)
shiv gaur
shiv gaur on 25 Jan 2022
Commented: shiv gaur on 25 Jan 2022
% n1=1.512;
% n2=1.521;
% n3=4.1-1i*0.211;
%
% n4=1;
% lambda = 633;
% k0 = (2*pi)/lambda;
% t2 = 50;
% t3=0;
T3=1e-9:1e-9:1e-6;
for i=1:numel(T3)
t3=T3(i);
[b]=fminsearch(@(b) abs(trial0(complex(b(1),b(2)))) ,[1,1]);
beta=complex(b(1),b(2))
end
plot(T3,real(beta))
function beta1 = trial0(beta,t3)
n1=1.512;
n2=1.521;
n3=4.1-1i*0.211;
n4=1;
lambda = 633e-9;
k0 = (2*pi)/lambda;
t2 = 2e-6;
%t3=0;
m=0;
S1 = k0*sqrt(n1^2-beta^2);
S2 = k0*sqrt(n2^2-beta^2);
S3 = k0*sqrt(n3^2-beta^2);
S4 = k0*sqrt(n4^2-beta^2);
beta1=-(S2)*t2+atan(S1/1i*S2)+atan((S3/S2).*tan(atan(S4/1i*S2)-S3*t3))+m*pi;
end
how to plot this equation value is getttng the no plot

Answers (1)

Walter Roberson
Walter Roberson on 25 Jan 2022
T3=1e-9:1e-9:1e-6;
for i=1:numel(T3)
t3=T3(i);
[b]=fminsearch(@(b) abs(trial0(complex(b(1),b(2)), t3)) ,[1,1]);
beta(i)=complex(b(1),b(2));
end
plot(T3,real(beta))
function beta1 = trial0(beta,t3)
n1=1.512;
n2=1.521;
n3=4.1-1i*0.211;
n4=1;
lambda = 633e-9;
k0 = (2*pi)/lambda;
t2 = 2e-6;
%t3=0;
m=0;
S1 = k0*sqrt(n1^2-beta^2);
S2 = k0*sqrt(n2^2-beta^2);
S3 = k0*sqrt(n3^2-beta^2);
S4 = k0*sqrt(n4^2-beta^2);
beta1=-(S2)*t2+atan(S1/1i*S2)+atan((S3/S2).*tan(atan(S4/1i*S2)-S3*t3))+m*pi;
end
  3 Comments
Walter Roberson
Walter Roberson on 25 Jan 2022
I do not encounter the problem.
T3=1e-9:1e-9:1e-6;
for i=1:numel(T3)
t3=T3(i);
[b]=fminsearch(@(b) abs(trial0(complex(b(1),b(2)), t3)) ,[1,1]);
beta(i)=complex(b(1),b(2));
end
figure
plot(T3,real(beta)); title('real')
figure
plot(T3, imag(beta)*1e5); title('imag')
function beta1 = trial0(beta,t3)
n1=1.512;
n2=1.521;
n3=4.1-1i*0.211;
n4=1;
lambda = 633e-9;
k0 = (2*pi)/lambda;
t2 = 2e-6;
%t3=0;
m=0;
S1 = k0*sqrt(n1^2-beta^2);
S2 = k0*sqrt(n2^2-beta^2);
S3 = k0*sqrt(n3^2-beta^2);
S4 = k0*sqrt(n4^2-beta^2);
beta1=-(S2)*t2+atan(S1/1i*S2)+atan((S3/S2).*tan(atan(S4/1i*S2)-S3*t3))+m*pi;
end
shiv gaur
shiv gaur on 25 Jan 2022
this fig is not visible if we want to plot 1e-9 to 1e-7 vs abs( imag(beta)*1e5)
pl help

Sign in to comment.

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Tags

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!