필터 지우기
필터 지우기

Calculate the Area Between Two Curves

조회 수: 1 (최근 30일)
Allison Bushman
Allison Bushman 2019년 3월 5일
답변: Rik 2019년 3월 5일
I am trying to calculate the area between these two curves:
cP6(k,:)=P6;
cP7(k,:)=P7;
plot(cP6(:,1),cP6(:,2),'LineWidth',2,'Color','red');
plot(cP7(:,1),cP7(:,2),'LineWidth',2,'Color','blue');

답변 (1개)

Rik
Rik 2019년 3월 5일
This code should help. It assumes you want to count all the area between the two lines as positive. The more crossings there are, the more this code will give an overestimation.
cP6(k,:)=P6;
cP7(k,:)=P7;
x1=cP6(:,1);
y1=cP6(:,2);
%x2=cP7(:,1);
y2=cP7(:,2);
%if x1 and x2 are not the same, you will need to resample them,
%or use polyarea instead of trapz
A=trapz(x1,abs(y1-y2));

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by