n1 = 1.5;

n2 = linspace(1,2);

theta = linspace(0,pi/2,2000);



for k = 1:length(n2)

    n21 = n2(k)/n1;

    r = (cos(theta)-sqrt(n21^2-sin(theta).^2))./(cos(theta)+sqrt(n21^2-sin(theta).^2));

    for j = 1:length(r)

        if (~isreal(r(j)))

            r(j) = 1;

        end

    end

    t = 1+r;

    plot(180/pi*theta,t);

    xlim([0 90]);

    ylim([-1.2 1.2]);

    xlabel('Incident angle');

    ylabel('Transmission coefficient');

    drawnow;

end