clc; clear; close all;
% Given values
n1 = 1.00; % Refractive index of medium 1 (air)
n2 = 1.44; % Refractive index of medium 2
n = n2 / n1; % Relative refractive index
theta_i = linspace(0, pi/2, 1000); % Angle of incidence from 0 to 90 degrees
in radians
% Compute reflection coefficients r_parallel and r_perpendicular
cos_theta_i = cos(theta_i);
sin_theta_i = sin(theta_i);
sqrt_term = sqrt(n^2 - sin_theta_i.^2);
r_parallel = (sqrt_term - n^2 .* cos_theta_i) ./ (sqrt_term + n^2 .*
cos_theta_i);
r_perpendicular = (cos_theta_i - sqrt_term) ./ (cos_theta_i + sqrt_term);
% Compute phase changes phi_parallel and phi_perpendicular
tan_phi_parallel_half = sqrt((sin_theta_i.^2 - n^2) ./ (n^2 .* cos_theta_i));
tan_phi_perpendicular_half = sqrt((sin_theta_i.^2 - n^2) ./ cos_theta_i);
phi_parallel = 2 * atan(tan_phi_parallel_half) - pi;
phi_perpendicular = 2 * atan(tan_phi_perpendicular_half);
% Plot reflection coefficients
figure;
plot(rad2deg(theta_i), r_parallel, 'r', 'LineWidth', 2); hold on;
plot(rad2deg(theta_i), r_perpendicular, 'b', 'LineWidth', 2);
xlabel('Angle of Incidence (\theta_i) [degrees]');
ylabel('Reflection Coefficients');
legend('r_{\parallel}', 'r_{\perp}');
title('Reflection Coefficients vs. Angle of Incidence');
grid on;
% Plot phase changes
figure;
plot(rad2deg(theta_i), phi_parallel, 'r', 'LineWidth', 2); hold on;
plot(rad2deg(theta_i), phi_perpendicular, 'b', 'LineWidth', 2);
xlabel('Angle of Incidence (\theta_i) [degrees]');
ylabel('Phase Change [radians]');
legend('\phi_{\parallel}', '\phi_{\perp}');
title('Phase Change vs. Angle of Incidence');
grid on;