samedi 29 novembre 2014

How to average the 5 past altitude values from the iPhone barometer

I'm creating an application that displays the variation of altitude using the new iPhone6 barometer. Although the output data has noise so I would like to apply a 5 points moving average to smooth data.


Here is the code I have to calculate the altitude difference from the most recent timestamp to the previous timestamp.



CGFloat degree = (_altData.relativeAltitude.floatValue - _prevAltData.relativeAltitude.floatValue)


I need to store and retrive the additional 3 previous data and average them. Thanks in advance, I'm new to Xcode and this would really help.




Aucun commentaire:

Enregistrer un commentaire