Calculating slopes every second I have a set of 3000 GPS records, for which I have calculated the grade of slope between each record. Records are generally recorded 1 second apart, but sometimes this time gap varies. Each record contains horizontal speed and altitude.
I use the following equation to determine the grade of each record, relative to the previous record.
I determine the vertical speed as:
(Altitude Record 2 - Altitude Record 1) * 1000 / (Time Record 2 - Time Record 1)
Then I calculate the grade as a percentage as follows:
Vertical Speed / Horizontal Speed * 100
The problem is, I have seen grade percentages that are over 4800%, with a vertical speed of -0.5m/s and horizontal speed of 0.02778m/s.
Even without this crazy outlier, spread over 3000 records, the slope percentage has fluctuated between -10% and 35%.
I don't think this is a good way to present grade, so I am looking for a better solution. Is this data better spread out over a 10 second period?
 A: Why are you multiplying by $1000$ in your speed equation?  Presumably that is a conversion factor, like your altitudes are in thousands of feet.  Probably your problem is that there is noise in the altitude values, as GPS is much less accurate in that direction.  Even a 20 foot error in horizontal position can lead to an error of 40 feet/second or almost 30 miles/hour in horizontal speed.  Going to longer intervals will help.  10 second averaging will reduce the error by a factor 10.  You can do even better by doing a linear regression.  Take 10 or 30 seconds of data points, assume the motion is constant over the interval, do a linear fit to the position as a function of time, and find the slope of the result.  For intervals where the motion changes, like you start up a hill, you will get an average value.  You can check the goodness of fit and reject those that don't fit well.  Any numerical analysis book can give you guidance.  I like Chapter 15 of Numerical Recipes.  Excel also has tools to do this, as to many software packages.
