Documentation 
Implement spherical harmonic representation of planetary gravity
[gx gy gz]
= gravitysphericalharmonic(planet_coordinates)
[gx gy gz]
= gravitysphericalharmonic(planet_coordinates, model)
[gx gy gz]
= gravitysphericalharmonic(planet_coordinates, degree)
[gx gy gz]
= gravitysphericalharmonic(planet_coordinates, model, degree)
[gx gy gz]
= gravitysphericalharmonic(planet_coordinates, model, degree, action)
[gx gy gz]
= gravitysphericalharmonic(planet_coordinates,
'Custom', degree, {datafile
dfreader}, action)
[gx gy gz] = gravitysphericalharmonic(planet_coordinates) implements the mathematical representation of spherical harmonic planetary gravity based on planetary gravitational potential. This function calculates arrays of N gravity values in the xaxis, yaxis, and zaxis of the PlanetCentered PlanetFixed coordinates for the planet. It performs these calculations using planet_coordinates, an Mby3 array of PlanetCentered PlanetFixed coordinates. By default, this function assumes 120th degree and order spherical coefficients for the 'EGM2008' (Earth) planetary model.
[gx gy gz] = gravitysphericalharmonic(planet_coordinates, model) implements the mathematical representation for the planetary model, model.
[gx gy gz] = gravitysphericalharmonic(planet_coordinates, degree) uses the degree and order that degree specifies.
[gx gy gz] = gravitysphericalharmonic(planet_coordinates, model, degree) uses the degree and order that degree specifies. model specifies the planetary model.
[gx gy gz] = gravitysphericalharmonic(planet_coordinates, model, degree, action) uses the specified action when input is out of range.
[gx gy gz] = gravitysphericalharmonic(planet_coordinates, 'Custom', degree, {datafile dfreader}, action) implements the mathematical representation for a custom model planet. datafile defines the planetary model. dfreader specifies the reader for datafile.
This function has the following limitations:
The function excludes the centrifugal effects of planetary rotation, and the effects of a precessing reference frame.
Spherical harmonic gravity model is valid for radial positions greater than the planet equatorial radius. Minor errors might occur for radial positions near or at the planetary surface. The spherical harmonic gravity model is not valid for radial positions less than planetary surface.
planet_coordinates 
Mby3 array of PlanetCentered PlanetFixed coordinates in meters. The zaxis is positive toward the North Pole. If model is 'EGM2008' or 'EGM96' (Earth), the planet coordinates are ECEF coordinates.  
model 
String that specifies the planetary model. Default is 'EGM2008'. Specify one: When inputting a large PCPF array and a high degree value, you might receive an outofmemory error. For more information about avoiding outofmemory errors in the MATLAB environment, see Memory Usage. When inputting a large PCPF array, you might receive a maximum matrix size limitation. To determine the largest matrix or array that you can create in the MATLAB environment for your platform, see Memory Usage.  
degree 
Scalar value that specifies the degree and order of the harmonic gravity model.
When inputting a large PCPF array and a high degree value, you might receive an outofmemory error. For more information about avoiding outofmemory errors in the MATLAB environment, see Memory Usage. When inputting a large PCPF array, you might receive a maximum matrix size limitation. To determine the largest matrix or array that you can create in the MATLAB environment for your platform, see Memory Usage.  
action 
String that defines action for outofrange input. Specify one:
 
'Custom' 
String that specifies that datafile contains definitions for a custom planetary model.  
datafile 
File that contains definitions for a custom planetary model. For an example of file content, see aerogmm2b.mat. This file must contain the following variables.
This parameter requires that you specify a program in the dfreader parameter to read the data file.  
dfreader 
Specify a MATLAB function to read datafile. The reader file that you specify depends on the file type of datafile.

gx 
Array of N gravity values in the xaxis of the PlanetCentered PlanetFixed coordinates in meters per second squared (m/s^{2}). 
gy 
Array of N gravity values in the yaxis of the PlanetCentered PlanetFixed coordinates in meters per second squared (m/s^{2}). 
gz 
Array of N gravity values in the zaxis of the PlanetCentered PlanetFixed coordinates in meters per second squared (m/s^{2}). 
Calculate the gravity in the xaxis at the equator on the surface of Earth. This example uses the default 120 degree model of EGM2008 with default warning actions:
gx = gravitysphericalharmonic( [6378.1363e3 0 0] )
Calculate the gravity at 25000 m over the south pole of Earth. This example uses the 70 degree model of EGM96 with error actions:
[gx, gy, gz] = gravitysphericalharmonic( [0 0 6381.751e3], 'EGM96', 'Error' )
Calculate the gravity at 15000 m over the equator and 11000 m over the North Pole. This example uses a 30th order GMM2B Mars model with warning actions:
p = [2412.648e3 2412.648e3 0; 0 0 3376.2e3] [gx, gy, gz] = gravitysphericalharmonic( p, 'GMM2B', 30, 'Warning' )
Calculate the gravity at 15000 m over the equator and 11000 m over the North Pole. This example uses a 60th degree custom planetary model with no actions:
p = [2412.648e3 2412.648e3 0; 0 0 3376e3] [gx, gy, gz] = gravitysphericalharmonic( p, 'custom', 60, ... {'GMM2BC80_SHA.txt' @astReadSHAFile}, 'None' )
Calculate the gravity at 25000 meters over the south pole of Earth using a 120th order EIGENGL04C Earth model with warning actions:
p = [0 0 6381.751e3] [gx, gy, gz] = gravitysphericalharmonic( p, 'EIGENGL04C', ... 120, 'Warning' )
[1] Gottlieb, R. G., "Fast Gravity, Gravity Partials, Normalized Gravity, Gravity Gradient Torque and Magnetic Field: Derivation, Code and Data," Technical Report NASA Contractor Report 188243, NASA Lyndon B. Johnson Space Center, Houston, Texas, February 1993.
[2] Vallado, D. A., Fundamentals of Astrodynamics and Applications, McGrawHill, New York, 1997.
[3] "NIMA TR8350.2: Department of Defense World Geodetic System 1984, Its Definition and Relationship with Local Geodetic Systems".
[4] Konopliv, A. S., S. W. Asmar, E. Carranza, W. L. Sjogen, D. N. Yuan., "Recent Gravity Models as a Result of the Lunar Prospector Mission, Icarus", Vol. 150, no. 1, pp 1–18, 2001.
[5] Lemoine, F. G., D. E. Smith, D.D. Rowlands, M.T. Zuber, G. A. Neumann, and D. S. Chinn, "An improved solution of the gravity field of Mars (GMM2B) from Mars Global Surveyor", Journal Of Geophysical Research, Vol. 106, No. E10, pp 2335923376, October 25, 2001.
[6] Kenyon S., J. Factor, N. Pavlis, and S. Holmes, "Towards the Next Earth Gravitational Model", Society of Exploration Geophysicists 77th Annual Meeting, San Antonio, Texas, September 23–28, 2007.
[7] Pavlis, N.K., S.A. Holmes, S.C. Kenyon, and J.K. Factor, "An Earth Gravitational Model to Degree 2160: EGM2008", presented at the 2008 General Assembly of the European Geosciences Union, Vienna, Austria, April 13–18, 2008.
[8] Grueber, T., and A. Köhl, "Validation of the EGM2008 Gravity Field with GPSLeveling and Oceanographic Analyses", presented at the IAG International Symposium on Gravity, Geoid & Earth Observation 2008, Chania, Greece, June 23–27, 2008.
[9] Förste, C., Flechtner, F., Schmidt, R., König, R., Meyer, U., Stubenvoll, R., Rothacher, M., Barthelmes, F., Neumayer, H., Biancale, R., Bruinsma, S., Lemoine, J.M., Loyer, S., "A Mean Global Gravity Field Model From the Combination of Satellite Mission and Altimetry/Gravmetry Surface Data  EIGENGL04C", Geophysical Research Abstracts, Vol. 8, 03462, 2006.
[10] Hill, K. A. (2007). Autonomous Navigation in Libration Point Orbits. Doctoral dissertation, University of Colorado, Boulder. http://ccar.colorado.edu/geryon/papers/Misc/Hill_thesis.pdf.
[11] Colombo, Oscar L., "Numerical Methods for Harmonic Analysis on the Sphere", Reports of the department of Geodetic Science, Report No. 310, The Ohio State University, Columbus, OH., March 1981.
[12] Colombo, Oscar L., "The Global Mapping of Gravity with Two Satellites", Nederlands Geodetic Commission, vol. 7 No. 3, Delft, The Nederlands, 1984., Reports of the department of Geodetic Science, Report No. 310, The Ohio State University, Columbus, OH., March 1981.
[13] Jones, Brandon A. (2010). Efficient Models for the Evaluation and Estimation of the Gravity Field. Doctoral dissertation, University of Colorado, Boulder. http://ccar.colorado.edu/geryon/papers/Misc/bajones_phd.pdf.
geoidegm96  gravitycentrifugal  gravitywgs84  gravityzonal