function ph_out = r2p(ph_array_in)
% ph_array_out = r2p(ph_array_in)
%
% Translate phasors from rectangular or polar form to polar form.
% Phasors represented in unique way:
%   [a+jb, 0] (1st value complex, 2nd value zero) represents a + bi  (rectangular form)
%   [A, phi] (1st value real, 2nd value real)  represents Ae^i*phi  (polar form)
%            phi is in degrees
%
% Each row of ph_array_in (and ph_array_out) is one phasor.

  % Step through phasors using for loop.
  for index_ph = size(ph_array_in,1)
    % Extract the phasor.
    ph = ph_array_in(index_ph,:);

    % Calculate phasor in rectangular form.
    rect_ph = ph(1)*(cosd(ph(2) + j*sin(ph(2)));

    polar_ph = [abs(rect_ph), atan2(imag(ph(1)),real(ph(1)))*180/pi];

    ph_out(index_ph,:) = polar_ph;
  end

end

