% SWR and plot of standing waves for different values of the pressure reflection coefficient R

c2overc1 = 1.2;
z2overz1 = 0.6;
incidentangle = 0:0.01:pi/2;
transmittedangle = asin(c2overc1 * sin(incidentangle)); % Snell's law

plot(incidentangle / pi * 180, real(transmittedangle) / pi * 180, 'linewidth', 2)
xlabel('\theta_i')
ylabel('Re({\bf\theta_t})')
set(gca, 'fontsize', 14)
grid
v = [0 90 0 90]; axis(v)
xticks(0:15:90)
yticks(0:15:90)

criticalangle = asin(1/c2overc1) / pi * 180

R = (z2overz1 ./ cos(transmittedangle) - 1 ./ cos(incidentangle) ) ./ ...
(z2overz1 ./ cos(transmittedangle) + 1 ./ cos(incidentangle) );

plot(incidentangle / pi * 180, abs(R), 'linewidth', 2)
set(gca, 'fontsize', 14)
xlabel('\theta_i')
ylabel('|R|')
v = [0 90 0 1]; axis(v)
xticks(0:15:90)
grid

angleofintromission = asin(((z2overz1^2 - 1) / (z2overz1^2 - c2overc1^2))^0.5) / pi * 180


