How I get area under the curve (AUC) value

조회 수: 3 (최근 30일)
Gyujin Park
Gyujin Park 2023년 10월 18일
댓글: Star Strider 2023년 10월 18일
Hello,
I am super bigginer at Matlab. I want to get AUC value only positive value.
which mean without Area over the curve value.
I using this code which I googled and learn from matlab Q&A. But this is for all area value.
>> D = readmatrix('F:\z-score.xlsx','Sheet','a','Range','B2:H50002');
>> t = D(1,:);
>> t = linspace(min(t), max(t), numel(t));
>> y1 = (D(6,:));
>> plot (t, y1);
>> area (t, y1);
>> polyarea (t,y1);
Thank you so much!

채택된 답변

Star Strider
Star Strider 2023년 10월 18일
편집: Star Strider 2023년 10월 18일
The file is not provided, however it is not absolutely necessary for this.
Try something like this —
D = 0.1*randn(6,12000)+(2*sin(6*pi*(0:11999)/11999));
t = linspace(0, 600, 12000);
y1 = D(6,:);
Lv = y1 >= 0;
AUc_pos = trapz(t(Lv),y1(Lv))
AUc_pos = 387.4466
figure
plot (t, y1);
hold on
patch([t(Lv) flip(t(Lv))], [zeros(size(y1(Lv))) flip(y1(Lv))], 'g', 'EdgeColor','g')
hold off
.
  댓글 수: 4
Gyujin Park
Gyujin Park 2023년 10월 18일
thank you so much!
very helpful code for me
Star Strider
Star Strider 2023년 10월 18일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by