The xyz2latlon
function in MATLAB converts Cartesian coordinates (x,y,z) to geodetic coordinates (latitude, longitude, and height) and also calculates the 3x3 covariance matrix for the geodetic coordinates. The function takes nine input arguments (x,y,z,sx,sy,sz,sxy,syz,sxz) and one optional input argument (fast), and returns six output arguments (lat,lon,h,slat,slon,sh,covl).
Here is the function signature and brief description of input and output arguments:
function [lat,lon,h,slat,slon,sh,covl]=xyz2latlon(x,y,z,sx,sy,sz,sxy,syz,sxz,fast)
% Convert Cartesian coordinates (x,y,z) to geodetic coordinates (latitude, longitude, and height)
% and calculates a 3x3 covariance matrix for the geodetic coordinates.
%
% Inputs:
% x, y, z: Cartesian coordinates (meters)
% sx, sy, sz: standard deviations of x, y, z (meters)
% sxy, syz, sxz: covariances between x,y; y,z; x,z (meters^2)
% fast (optional): if true, use a faster but less accurate algorithm
%
% Outputs:
% lat, lon, h: geodetic coordinates (degrees, degrees, meters)
% slat, slon, sh: standard deviations of lat, lon, and h (meters)
% covl: 3x3 covariance matrix for lat, lon, h
Here is an example usage of the function: