Calculate the Area Between Two Curves

2 次查看(过去 30 天)
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