How can I calculate the area between two curves?
7 views (last 30 days)
Show older comments
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!
0 Comments
Answers (1)
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
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.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!