To calculate the area under a series of curves

2 ビュー (過去 30 日間)
Vahid Esmaeili
Vahid Esmaeili 2020 年 7 月 28 日
コメント済み: Star Strider 2020 年 7 月 29 日
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 Center および File ExchangeSpline Postprocessing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by