%------------------------------------------------------------
% Tony Hyun Kim
% 8.07: PS#9, Problem 4 
%       Sketch of Fresnel equations
%------------------------------------------------------------
n_i = 1;
n_t = 1.5;

M = 1000;
theta_i = linspace(0,pi/2,M);
theta_t = asin(n_i/n_t*sin(theta_i));

E_t = 2*cos(theta_i)./(cos(theta_i)+n_t/n_i*cos(theta_t));
E_r = (n_i*cos(theta_i) - n_t*cos(theta_t))./...
        (n_i*cos(theta_i) + n_t*cos(theta_t));

plot(180/pi*theta_i,E_t,'linewidth',2);
hold on;
plot(180/pi*theta_i,E_r,'r','linewidth',2);
grid on;
xlabel('Incident angle \theta_I (degrees)');
ylabel('Reflection and Transmission coefficients');
title('Fresnel equations for TE mode incidence (n_2/n_1 = 1.5)');
legend('Transmitted wave','Reflected wave',3);