# getting the area under the peaks

2 vues (au cours des 30 derniers jours)
Rashid Hussein le 18 Nov 2017
Commenté : Star Strider le 19 Nov 2017
I have a graph that contain many peaks , but I want to get the sum( area under peak) of counts (y-axis) in every peaks as shown in the image that I uploaded , thanks in advanced
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Star Strider le 18 Nov 2017
I would first identify the low points (‘valleys’) by inverting your signal and then using the Signal Processing Toolbox findpeaks function to locate them. Then integrate between those points to identify the peaks.
Example
t = linspace(0, 10*pi, 250); % Create Data
s = sin(t) + 0.2*cos(5*t) + 2; % Create Data
figure(1)
plot(t, -s)
grid
[Vlys, Idx] = findpeaks(-s, 'MinPeakHeight',-1.1);
Area = cumtrapz(t,s);
idxvct = [1 Idx length(s)];
for k1 = 1:length(idxvct)-1
PkAreas(k1) = Area(idxvct(k1+1)) - Area(idxvct(k1));
end
The ‘PkAreas’ vector will have the areas of the peaks.
You will have to adapt this to your data. Be sure to plot the negative of your data first so you can see and set the appropriate arguments for findpeaks.
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Star Strider le 19 Nov 2017
My pleasure.
My code creates the cumulative integral, identifies the valleys, then uses those indices to separate and calculate the areas for each peak in the ‘PkAreas’ vector.
My code worked correctly with the data I created to test it, because I do not have your data to test it with. You have included my code, although you commented it out.

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Descriptive Statistics dans Help Center et File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by