MATLAB: Am I not getting the plot results

equationfunctionsMATLABmatrix arrayplotting

c = 3e8;
h = 50e-9;
ramd = 633.0d-9;
omega = 2*pi/ramd*c;
e2 = 1;
enpr = 1.723;
e1 = -11.67345024 + 1i*1.1809292;
theta = 35*pi/180: 0.001 : 45*pi/180;
rpr1 = (cos(theta)/enpr - sqrt((e1-enpr^2*sin(theta).^2)/e1)) / (cos(theta)/enpr + sqrt(e1-enpr^2*sin(theta).^2)/e1);
r12 = (sqrt(e1-enpr^2*sin(theta).^2)/e1 - sqrt(e2-enpr^2*sin(theta).^2)/e2) / (sqrt(e1-enpr^2*sin(theta).^2)/e1 + sqrt(e2-enpr^2*sin(theta).^2)/e2);
alpha = 2*omega/c*h*sqrt(e1-enpr^2*sin(theta).^2)*1i;
R = (rpr1 + r12*exp(alpha))/(1 + rpr1*r12*exp(alpha));
t = theta/pi*180;
plot(t,abs(R));

Best Answer

  • The below code produces plot as you expect:
    c = 3e8;
    h = 50e-9;
    ramd = 633.0d-9;
    omega = 2.*pi/ramd*c;
    e2 = 1;
    enpr = 1.723;
    e1 = -11.67345024 + 1i*1.1809292;
    theta = 35*pi/180: 0.001 : 45*pi/180;
    rpr1 = (cos(theta)./enpr - sqrt((e1-enpr.^2.*sin(theta).^2)./e1)) ./ (cos(theta)./enpr + sqrt(e1-enpr.^2.*sin(theta).^2)./e1);
    r12 = (sqrt(e1-enpr.^2.*sin(theta).^2)./e1 - sqrt(e2-enpr.^2.*sin(theta).^2)./e2) ./ (sqrt(e1-enpr.^2.*sin(theta).^2)./e1 + sqrt(e2-enpr.^2.*sin(theta).^2)./e2);
    alpha = 2.*omega./c.*h.*sqrt(e1-enpr.^2.*sin(theta).^2).*1i;
    R = (rpr1 + r12.*exp(alpha))./(1 + rpr1.*r12.*exp(alpha));
    t = theta./pi*180;
    plot(t,abs(R));