How can I calculate the areas between these two curves?

조회 수: 6 (최근 30일)
Jose Aroca
Jose Aroca 2020년 7월 15일
댓글: Jose Aroca 2020년 7월 26일
I need to calculate both areas A and B that lie between these two curves. The curves are extracted form two text files, which are attatched. The code below shows how the graph is produced.
close all
clearvars
DM = readtable('FF677-Di01.txt');
plot (DM{:,1},DM{:,2})
hold on
AF = readtable('Alexa Fluor 647 - Em.txt');
plot (AF{:,1},AF{:,2})
A = intersect(DM{:,1}, AF{:,1});
xlim ([500 900])
hold on
AArea = trapz(AF{:,1},AF{:,2});
DMArea = trapz(DM{:,1},DM{:,2});

답변 (1개)

Dinesh Yadav
Dinesh Yadav 2020년 7월 22일
To calculate the area B change the follwing line of code
AArea = trapz(AF{:,1},AF{:,2});
to
AArea = abs(trapz(AF{:,1},(AF{:,2} - DM{:,2} )));
and to compute area A calculate the area under the AF and subtract AArea from it
DMArea = abs(trapz(AF1{:,1},AF{:,2} - AArea);
  댓글 수: 1
Jose Aroca
Jose Aroca 2020년 7월 26일
Hi. First of allm thank you for your answer. I have tried adding your suggestions but I don't think I get the correct answer. I get an area for B of about 490, when it should be about 20.5, and therefore the area calculated for A is also wrong. I am not sure how to correct this.

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

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by