- Identify the peak as y-values greater than the upper 95% confidence interval for the mean of all the data;
- Integrate the entire record using cumtrapz;
- Do a linear regression on all the integrated data up to the first index of the peak;
- Use that regression to detrend the integrated data;
- Use the identified indices of the peak to calculate the approximate integral of the peak.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/175724/image.png)