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,
0 个评论
采纳的回答
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 个评论
更多回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!