File Exchange

image thumbnail


version (9.72 MB) by Meysam Mahooti
The SGP4 model to calculate orbital state vectors of near-Earth satellites


Updated 02 Apr 2020

View Version History

View License

Simplified perturbations models are a set of five mathematical models (SGP, SGP4, SDP4, SGP8 and SDP8) used to calculate orbital state vectors of satellites and space debris relative to the Earth-centered inertial coordinate system. This set of models is often referred to collectively as SGP4 due to the frequency of use of that model particularly with two-line element sets produced by NORAD and NASA. These models predict the effect of perturbations caused by the Earth’s shape, drag, radiation, and gravitation effects from other bodies such as the sun and moon. Simplified General Perturbations (SGP) models apply to near earth objects with an orbital period of less than 225 minutes. Simplified Deep Space Perturbations (SDP) models apply to objects with an orbital period greater than 225 minutes, which corresponds to an altitude of 5,877.5 km, assuming a circular orbit.
The SGP4 model was developed by Ken Cranford in 1970. This model was obtained by simplification of the more extensive analytical theory of Lane and Cranford which uses the solution of Brouwer for its gravitational model and a power density function for its atmospheric model.

Cite As

Meysam Mahooti (2021). SGP4 (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (36)

Carlos Sarno

Ignore my last comment. I was actually referring to, which includes Vallado's code. It is that which seems to have a time offset issue. Just running your code and noting you need the eop file to have just data and no header (eop file from celestrak has a header) I get very good agreement with GPredict! Thanks.

Carlos Sarno

Hi. Good work. I've used your software to predict the Doppler of a particular Iridium satellite from my location to compare with Doppler I've calculated from some data I captured with an SDRplay RSPdx (I'm looking at the primary messaging, quaternary messaging and Ring Alert channels). I also compared the Doppler with predictions using GPredict. The Doppler from my SDR data tied up with GPredict very well, but the Doppler using positions generated from your program seemed to suggest there is an offset in time, by about 12-13 seconds. Any ideas? Cheers

Meysam Mahooti

Dear Sunip,
Please update eop19620101.txt from
Best regards,

Sunip Mukherjee


Call to IERS() fails with the following:

Index exceeds the number of array elements (0).

Error in IERS (line 26)
x_pole = preeop(5)+(nexteop(5)-preeop(5))*fixf;

Error in test (line 86)
[x_pole,y_pole,UT1_UTC,LOD,dpsi,deps,dx_pole,dy_pole,TAI_UTC] = IERS(eopdata,MJD_UTC,'l');

This seems to be triggered whenever the epoch year is greater than 19. Could you suggest any possible fix?


Mehrdad Afian

Mehrdad Afian

Hi Meysam
I had a question about your SGP4 program, my question is that this program shows the following error for some TLEs, can you explain the reason for that?
Index exceeds the number of array elements (0).

Error in IERS (line 26)
x_pole = preeop(5)+(nexteop(5)-preeop(5))*fixf;

Error in test_sgp4 (line 112)
[x_pole,y_pole,UT1_UTC,LOD,dpsi,deps,dx_pole,dy_pole,TAI_UTC] = IERS(eopdata,MJD_UTC,'l');

Thanks a lot

Mehmet Rauf Geden

Ziming Ren

when I compare the lla from this with stk, it doesn't match with each other. I just change the tle and eop2021.txt. Does anybody can help me solve this question..? Thanks!

Young Nam

Works very well for the IRIDIUM Next constellation

Thamer Sam


Great job, well written code but has author ever compared the ground track he calculated with actual ground track of the satellite? I've compared actual METOP-C ground track with simulated one and
I see the phase shift between those tracks. The track pattern is the same, but simulated track is 5 degrees the behind actual one. Not sure what is wrong and how this timing issue happens.

Kazuko Hagiwara

Murat Bulut

Feng Xuefeng

Josue Pareja

Andy Williams

Hung Nguyen

If I want "tsince" to be in seconds, what do I need to change in the code? So far, the results (in ECEF) seem to be consistent with an orbital tool we're using for one-day run on a GPS TLE, within (-0.7,+0.6) in range, and (-3e-4,+5e-4) in velocity magnitude. Thanks for the code.

Hung Nguyen

Hi Meysam, do you have MATLAB code for SDP4 (orbital period greater than 225 minutes) model? If not can you give some pointers? Thanks

Meysam Mahooti

Dear Charith,
You will get your answer by reading the following paper:
Best regards,

Charith Ranatunga

Dear Meysam, I just used your code and its work accordingly amazing work, and thank you. How do I interpret the equinox coordinate system it has provided me? Im trying to get some rough calculations done for a CubeSat comms subsystem and I'm unsure how to use the result of the SGP4 code.

Meysam Mahooti

Dear Zhang,
You can download Earth orientation parameters (EOP) from the following link:
Best regards,


Where can I download IERS data? PLease send me the link . Thank you very much!


xiupeng Jiang

A good job!

Meysam Mahooti

The output of SGP4 by Vallado is based on equator mean equinox (TEME) coordinate system. Please compare your results with STK. Moreover, I am not sure STK has considered what type of coordinate system. I suggest use my version rather than Vallado's version.

Changyong He

Clear code! However, note that the output of spg4 is different from the sgp4 propagator written by Vallado. I cannot find the reason because there are no comments in your code.

Reid McCargar

Nowhere in code, comments, or (absent) readme are units or coordinate systems specified, which creates a tremendous amount of unnecessary work for any user.

shahin darvish

Dear Meysam, do you know why the results of sgp4 and STK are different?
(i tried sgp4 in Matlab,Python and C++ all of them had same result but different from STK!)

Muzammil Khan

Dear Meysam kindly tell me what tsince actually is? is it the time since epoch of the satellite or something else and also how to calculate tsince for a particular yy/mm/dd h:m:s

Meysam Mahooti

tsince in test_sg4.m is amount of time in minutes which you are going to propagate satellite's state vector forward (+) or backward (-).

Aakash Deep

Can you explain what is tsince in your code?

Wouter Huisman

Thanks for the upload! I was wondering why the sgp4 function does not work when I use an eccentricity of zero? In order to get it to work for circular orbits, should I just use a very small eccentricity to approximate a circular orbit? My inclination, RAAN, eccentricity, argument of perigee, mean anomaly, mean motion, and revolution number at epoch are:
96.8500 217.5000 0000001 0.00000 0.000000 15.68820425 000


Meisam Ashraf

Darren DeBattista


Thanks for the upload. How can I take time in consideration in order to propagate the satellite orbital position and velocity?

Michael Sampol

MATLAB Release Compatibility
Created with R2019b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: epoch2datevec(tle_epoch)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!