MATLAB: Get amplitude decrease as a function of time in damped harmonic oscillations

amplitudedamped harmonic oscillationsexponential fit

I have all values of position as a function of time, attached graph. I'm trying to fit an exponential function to the upper peaks. Any tips?
Related Question