MATLAB Answers

Value of x for which AUC reaches a given value

14 views (last 30 days)
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?

  0 Comments

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 18 Jan 2021
‘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')
.

  2 Comments

Alessandra Piatti
Alessandra Piatti on 18 Jan 2021
Thank you very much! This spared me a lot of banging my head against the wall!
Star Strider
Star Strider on 18 Jan 2021
As always, my pleasure!
(That sounds painful! Don’t do it!)

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!