you could try to get the peaks with the findpeaks method from Matlab, and then you for-loop backwards over the data array from the x value as the index and compare the data, as long as it is decreasing. I have made you an example for the first peak.
I attached you an example. Does this make sense? I get as a result 24.6050 for the first low to the first peak.
Of course you must for loop over all peaks and extend the thing! The example is only for the first peak.
My example gets you from that first detected peak to the bottom.
and this is the variable z, so the extracted data from the first peak in the figure above to the bottom. Then simply get the area underneath the data with the trapz method.If you want to ignore this little peaks and only head for the bigger ones, I think you can add a parameter to the findpeaks method.
data = [3.42
3.42
3.41
3.4
3.4
3.4
3.4
3.4
3.4
3.39
3.39
3.39
3.39
3.39
3.37
3.37
3.37
3.37
3.37
3.37
3.37
3.37
3.36
3.35
3.35
3.35
3.34
3.36
3.37
3.38
3.43
3.54
3.61
3.7
3.79
3.77
3.84
3.9
3.99
4.03
4.07
4.11
4.05
4
3.95
3.9
3.86
3.85
3.84
3.89
3.92
3.9
3.86
3.83
3.83
3.83
3.83
3.83
3.83
3.83
3.84
3.85
3.85
3.91
3.96
3.97
3.96
3.95
3.96
4.01
4.03
4
3.99
3.99
3.97
3.97
3.97
3.97
3.99
3.97
3.97
3.99
4
4
3.99
3.97
3.97
4
3.99
3.97
3.97
3.97
3.97
3.97
3.95
3.95
3.95
3.94
3.92
3.92
3.91
3.9
3.89
3.87
3.86
3.86
3.86
3.89
3.9
3.87
3.85
3.85
3.84
3.83
3.8
3.8
3.84
3.85
3.85
3.85
3.83
3.83
3.8
3.81
3.83
3.8
3.78
3.78
3.78
3.78
3.79
3.8
3.79
3.77
3.76
3.75
3.76
3.85
3.85
3.83
3.8
3.78
3.78
3.9
3.96
3.94
3.89
4.04
4.04
4.03
4.01
4
4.14
4.18
4.16
4.14
4.11
4.11
4.08
4.05
4.04
4.05
4.05
4.07
4.14
4.14
4.14
4.11
4.08
4.08
4.08
4.08
4.08
4.08
4.21
4.29
4.26
4.22
4.21
4.19
4.16
4.16
4.16
4.15
4.14
4.14
4.14
4.14
4.12
4.11
4.11
4.11
4.11
4.11
4.11
4.11
4.11
4.11
4.21
4.32
4.31
4.28
4.25
4.19
4.19
4.16
4.19
4.21
4.19
4.19
4.16
4.16
4.28
4.32
4.31
4.39
4.4
4.34
4.28
4.25
4.25
4.29
4.31
4.28
4.25
4.25
4.22
4.22
4.19
4.19
4.21
4.19
4.22
4.29
4.28
4.25
4.25
4.23
4.26
4.25
4.22
4.22
4.21
4.19
4.19
4.19
4.19
4.21
4.19
4.19
4.19
4.19
4.18
4.26
4.32
4.4
4.4
4.37
4.37
4.37
4.31
4.28
4.28
4.25
4.25
4.25
4.25
4.22
4.22
4.21
4.19
4.19
4.25
4.28
4.37
4.45
4.43
4.4
4.37
4.34
4.39
4.4
4.37
4.34
4.31
4.28
4.34
4.4
4.4
4.37
4.34
4.31
4.31
4.31
4.31
4.32
4.28
4.29
4.32
4.31
4.28
4.28
4.28
4.25
4.25
4.25
4.25
4.23
4.22
4.22
4.22]
[x,y] = findpeaks(data);
j = 1;
for i=y(1):-1:2
if data(i-1) < data(i)
z(j) = data(i);
j = j+1;
else
break;
end
end
z = flip(z);
area = trapz(z);