How can I calculate the area between two curves?

7 views (last 30 days)
The above picture represents the two curves in which I am trying to calculate the area between. Imagine that at the endpoints of each of the curves, a straight line connects both of the curves, closing them. I want to find the enclosed area between those two curves.
I have come across one method of evaluating the area between two curves (taking the numerical integrals between each curve using the "trapz" function and subtracting them) however in this case, it does not work because the curve turns back left.
I also tried separating the curves into two segments so that I could calculate the areas of each segment however, this also gives me unwanted area because I want the curves to be closed between the two endpoints.
I have 4 sets of data points to compute these integrals (x1 , y1, x2, y2), 1 and 2 being two different curves. I cannot give anymore information than this because I do not know what else is relevant to put. My question is how do you compute the area between the two enclosed curves given the information I have given.
Thank you for your assistance and your patience with the information I have provided!

Answers (1)

Star Strider
Star Strider on 9 Mar 2015
I would experiment by using trapz as you described, and then taking the absolute difference between them. That should correct for the ‘crossover’ problem.
  2 Comments
Xavier
Xavier on 9 Mar 2015
Thank you for the timely response. My only concern with this is understanding how the trapz function works or how integrals work in general when curve turns back (in this case curves turn back at 100m). It was under my assumption that you will not be able to integrate the function in this case.
Also, notice how the black line extends further left than the red. Integrating this will also receive the area underneath the extension which I do not want. If you imagined a straight line was drawn between the two endpoints of the function, I would like the area enclosed by the curves and the straight line.
Star Strider
Star Strider on 9 Mar 2015
The only approach I can think of is to segment it into a ‘top’ segment (the upper semicircle) and the ‘bottom’ segment (the rest) and integrate them both separately and take the absolute differences of both. That creates ‘functions’ out of both segments, so trapz should work.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!