function [az, elev, slantRange] = ecef2aer( ...
    x, y, z, lat0, lon0, h0, spheroid, angleUnit)
%

% Copyright 2012-2023 The MathWorks, Inc.

%#codegen

inDegrees = (nargin < 8 || map.geodesy.isDegree(angleUnit));

[xEast, yNorth, zUp] = ecef2enuFormula( ...
    x, y, z, lat0, lon0, h0, spheroid, inDegrees);

if inDegrees
    [az, elev, slantRange] = enu2aerFormula(xEast, yNorth, zUp, @atan2d);
else
    [az, elev, slantRange] = enu2aerFormula(xEast, yNorth, zUp, @atan2);
end
