Borrar filtros
Borrar filtros

Calculate the Area Between Two Curves

1 visualización (últimos 30 días)
Allison Bushman
Allison Bushman el 5 de Mzo. de 2019
Respondida: Rik el 5 de Mzo. de 2019
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');

Respuestas (1)

Rik
Rik el 5 de Mzo. de 2019
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));

Categorías

Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by