MATLAB: Value of x for which AUC reaches a given value

auc

Hello,
I need to find the point on the x axis where the AUC of a given curve reaches 50% of its value.
I calculate the AUC using the trapz function. I guess at this point I need a reverse formula to find the value of x there the AUC reaches a given value.
Could anybody please help me with that formula?

Best Answer

‘I calculate the AUC using the trapz function.
That being the problem. Use cumtrapz instead:
t = linspace(0, 1, 500); % Create Data

x = rand(size(t)); % Create Data
AUC = cumtrapz(t,x);
AUC50 = interp1(AUC, t, AUC(end)/2);
figure
plot(t, AUC)
hold on
plot(AUC50, AUC(end)/2, 'p')
hold off
text(AUC50, AUC(end)/2, sprintf('\\leftarrow AUC = %.2f at %.2f', AUC(end)/2, AUC50), 'HorizontalAlignment','left', 'VerticalAlignment','middle')
.
Related Question