# Issue with SGP4 modelling from scratch in MATLAB

I am trying to develop the code from this source , this research paper and from this too as same as bibliography of that aforementioned source.

So, here as you can see at page 14, they have defined the SGP4 model and from page 87 to 90, they have discussed about the constant values and parameters. At Page, 88 the value of $$XKE = k_e *(er/min)^{3/2}$$ where, $$er = Earth Radii$$ and min is $$minute?$$ Even if I put those values (er = $$6378.135km,$$ min = what should I put?) I did with $$60*24$$ I am not getting the exact same value of $$XKE$$ ? What are those values it could take?

I got the reference code from MATLAB because I am also working on MATLAB environment, so at there when they are exequting 'xke' (xke = sqrt((3600.0 * ge) / (xkmper^3))) how did they are getting this 3600? where ge is gravitational constant, xkmpr is Earth radii.

Problem is I have 2 different TLE and I have to propagate my spacecraft at least for a day with one second time step, but the code I got from MATLAB which only gives us one value at a time, I can't put loop at the whole model but I need data of Position, Velocity vector of each point in one second time steps for at least a day.

How can I solve this problem? Any short of leads would be helpful.

• What value of XKE are you getting? What value do you expect to get? – Organic Marble Oct 10 '19 at 1:01
• According that source what I have said on the question, I should get 0.0743669161331734, but I am getting 5885.26341335192. But at the MATLAB code which is already there they have used , xke = sqrt((3600.0 * ge) / (xkmper^3)) and I am not getting how and what is 3600 here? If I use the same formula I will get exact same number. But this MATLAB code give me only one point's Position, velocities vectors. If I need to get all points, with each second time step, I need to understand where they have use minutes/seconds/hours and then I have process the whole loop and I got stuck at xke. – JOY Oct 10 '19 at 1:09
• 3600 is likely the number of seconds in a hour. – Organic Marble Oct 10 '19 at 1:23
• There are six question marks in your question post and so it's too much work trying to figure out what your main question is from this. Can you try to focus on one single question that can have a correct answer by editing your question (not adding furhter explanations in comments)? Otherwise your question may be flagged as "unclear what you're asking" and eventually closed. Thanks! – uhoh Oct 10 '19 at 7:24
• @OrganicMarble - 3600 is most likely the number of seconds in a minute, squared. – David Hammen Oct 12 '19 at 3:51

## 1 Answer

You seem well aware that there is a reference implementation for SGP4 in Matlab. Yet you choose to make your own. I've sadly been there, and done that.

Your first problem is to compute XKE, but from the reference you've posted on page 88: And on page 89: Since G = 6.67408 × 10-11 m3 kg-1 s-2, GM has units of length³/time². Convert these units to Earth radii and minutes and you should reach the value given.

Regarding the Matlab issue, you should create a separate function for your SGP4 propagation and call it in a loop. I'm having a hard time wondering why you wouldn't be able to to that. But, if that is somehow a restraint you must respect, you can define a time vector since the TLE epoch with t = 0:1/60:24*60, which corresponds to a series starting at zero and going up to a day (in minutes) with one second interval. By rewriting the operations on SGP4 such as t^2 to be element wise such as in t.^2, you should be able to create a vectorized version of the code that runs all propagations at once without a loop. But this would be very memory demanding, and I would still suggest the loop approach.