How can I calculate the area between two curves in a specific section?
3 views (last 30 days)
I have two curves which have several intersection points (see attachment). I want to calculate the green filled area in between two intersection points. It works to calculate and display the intersection points. However I am struggling to calculate just this specific (green filled) area with the trapz function since there always pops up following error message:
"Index in position 1 is invalid. Array indices must be positive integers or logical values."
[xj,yj] = polyxpoly(x,y1,x,y2); %calculate intersection points %y1 straight line %y2 mean
mapshow(xj,yj,'DisplayType','point','Marker','o');%show intersection points
a = trapz(isec1:isec2,y1(isec1:isec2,1))-trapz(isec1:isec2 ,y2(isec1:isec2,1));