XYZ2GRAV - computes the gravitational acceleration vector at a specified ECEF location using the JGM2 gravitational ellipsoid only. Higher-order gravity terms (the "gravity anomaly") are ingnored. Only the pure ellipsoid is used.
[gx,gy,gz] = XYZ2GRAV(x,y,z)
x, y, z = Earth-Centered-Eacrth-Fixed (ECEF) cartesian coordinates (meters)
gx,gy,gz = components of gravitational acceleration in ECF (meters/sec^2)
(1) x,y,z may be scalars, vectors, or matrices but must have the same size and shape
(2) gx,gy,gz will have the same size/shape as x,y,z
(3) Only the ellipsoidal portion of the JGM-2 gravity model is used here.
(4) Points inside the earth will return gravity vectors, but will be higher in magnitude than physical reality since mass "above" the point is not removed from consideration; i.e., the ellipsoidal gravitational field surrounds a point at the center of the earth. The strength of the field increases as one gets closer to that central point.
(5) If all inputs are zero, then NaN is returned.
(6) Source of initial formulas:
(7) The gx & gy formulas were written in a more explicit form to prevent divergence when the x-coordinate is zero.
(8) The calculation was accelerated by precomputing some values.
(9) No warranty; use at your own risk.
Version 1.0 - Initial writing. Michael Kleder, August 2005
Michael Kleder (2021). Ellipsoidal Gravity Vector (https://www.mathworks.com/matlabcentral/fileexchange/8359-ellipsoidal-gravity-vector), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!