function mhand = polellise (phase, relpowr)
% function mhand = polellise (phase, relpowr)
% Plots an ellipse showing the polarization state of a harmonic 
% electromagnetic wave. Then shows movie of field vector movement.
% Input:
%   phase:   Relative phase of the two polarization components
%   relpowr: Relative fraction of power in vertical component.
% Output:
%   mhand:   Movie handle
%
arg =  pi*(0:0.05:2); % 41 sampling points in plot
if  relpowr < 0;  relpowr = 0;  end;
if  relpowr > 1;  relpowr = 1;  end;
Ey0 =  sqrt(relpowr);
Ex0 =  sqrt(1 - relpowr);
Ey  =  Ey0.*cos(arg - phase);
Ex  =  Ex0.*cos(arg);
plot(Ex,Ey);
title  ('Polarization State of EM-wave')
xlabel ('Horizontal Field Component')
ylabel ('Vertical Field Component')
axis ([-1 1 -1 1])
axis square
pause
% make movie with 41 time samples 
for t = 1:1:41
%   1) plot trajectory of field vector tip    
%   2) plot field vector
    plot(Ex,Ey,'b-',[0 Ex(t)], [0 Ey(t)], 'ok-'); 
    title  ('Polarization State of EM-wave')
    xlabel ('Horizontal Field Component')
    ylabel ('Vertical Field Component')
    axis ([-1 1 -1 1])
    axis square
    M(t) = getframe;
end
mhand = M;
return
