To calculate the area under a series of curves

1 次查看(过去 30 天)
Hello,
Would you please assist me to calculate the area under different sections of the curves of FR2_.mat? The sections are IC, LR, MS, TS, PS, P50, TOR.
The following lines calculate different sections of the curve like the photo attached to the question.
cycl=13;
for i=1:length(cycl)
if length(i+5)>length(FR2_)
break
end
LR(i)=find(FR2_(i,:)==max(FR2_(i,1:40)));
for j= LR:70
if FR2_(i,j+1)> FR2_(i,j)
MS(i)= find(FR2_(i,:)==( FR2_(i,j)));
end
end
end
for i=1:length(cycl)
IC(i)=find(FR2_(i,:)==min(FR2_(i,1:3)));
LR(i)=find(FR2_(i,:)==max(FR2_(i,1:40)));
TS(i)=find(FR2_(i,:)==max(FR2_(i,MS(i):85)));
PS(i)=find(FR2_(i,:)==max(FR2_(i,TS(i):99)));
P50(i)=find(FR2_(i,:)==min(FR2_(i,49:51)));
TOR(i)=find(FR2_(i,:)==min(FR2_(i,97:99)));
end
Also, there is a FL2_.mat. I have to find the points of FL2_.mat the correspond to the "IC, LR, MS, TS, PS, P50, TOR" points of FR2_. Then, I have to calculate area under these sections as well.
I appreciate your attention to this question.
Vahid,

采纳的回答

Star Strider
Star Strider 2020-7-28
First, the for loops should both be:
for i = 1:cycl
The areas calculation appears to be straightforward:
for i=1:cycl
AUC = cumtrapz(FR2_(i,:));
IC(i)=find(FR2_(i,:)==min(FR2_(i,1:3)));
LR(i)=find(FR2_(i,:)==max(FR2_(i,1:40)));
TS(i)=find(FR2_(i,:)==max(FR2_(i,MS(i):85)));
PS(i)=find(FR2_(i,:)==max(FR2_(i,TS(i):99)));
P50(i)=find(FR2_(i,:)==min(FR2_(i,49:51)));
TOR(i)=find(FR2_(i,:)==min(FR2_(i,97:99)));
Areas(i,:) = diff(AUC([IC(i) LR(i) TS(i) PS(i) P50(i) TOR(i)]));
end
See if that does what you want.
.
  4 个评论
Vahid Esmaeili
Vahid Esmaeili 2020-7-29
I modified the calculation of variables and now everything is OK.
Thanks
Star Strider
Star Strider 2020-7-29
As always, my pleasure!
I appreciate the follow-up!

请先登录,再进行评论。

更多回答(1 个)

KSSV
KSSV 2020-7-28
Read about trapz.

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by