MATLAB: How to calculate partial area-under-the-curve

aucplottrapz

Hi all,
I am trying to find the area under the curve (AUC) for a part of a graph. I use "trapz" function, but this function calculates the AUC for a entire area below the selected part of the graph. Any hint how I can calculate only part of it (not entire part until x-axis)? Please see figure. Interested are to be calculate is in red.
Thanks, Mehdi
(for simulation of data, just generate a random vector and try a part of it.)

Best Answer

Mehdi, use trapz twice to subtract the area below the red marked one (between x-axis and data points y = 0.3111, 0.1848 ) from the entire area.
Related Question