%
%   Book: MATLAB-Based Electromagnetics (Pearson Prentice Hall)
%   Author: Branislav M. Notaros
%   Instructor Resources
%   (c) 2011
%
%   This MATLAB code or any part of it may be used only for educational purposes associated with the book
%
%
%

function[R,PHI,Z] = car2Cyl(x,y,z)
R = sqrt(x^2 + y^2);
if (x==0 && y==0)
    PHI = 0;
elseif x>=0
    PHI = asin(y/R);
else
    PHI = -asin(y/R) + pi;
Z = z;
end;

