Calculate area between irregular unknown curve and straight line
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I have a series of data that are trajectories of cursor movements. Below are some of the trajectories that I have.


I need to find the area between each trajectory and its ideal straight line trajectory (a straight line from the first point to the last point). Both the mouse trajectories and straight line have been normalized to have 101 sets of coordinates each. The trajectories always start from (0, 0) and go to the top left or right of the screen. I have attached the coordinates of the 2 trajectories and lines in an Excel file.
My question is: How do I find the area between the curves and the straight lines? I do not have the functions of the curves, so I can't use any of the integral functions. I have tried to use trapz with the y-coordinate as the independent variable, i.e.,
trapz(traject1_y, traject1_x) - trapz(str_line1_y, str_line1_x)
While it returns me a value, I'm not really sure how that value is derived; the Matlab documentation on trapz does not provide a lot of details. Moreover, my understanding is that the functions for integration require the independent variable to increase monotonically, and that isn't the case for me, as you can see from the plots that I have attached. Is there another way to find the area?
Thanks in advance!
댓글 수: 11
Abdallah Abu Aisha
2018년 9월 4일
Hi Elin and Stijn, did you, by any chance, find a more "practical" way to find the sum of all areas between the two paths ( regardless positive or negative)? Since I am working on something very similar but for huge number of trips, so the solution proposed by Owaid doesn't work for my case. I have been struggling finding a function/code to solve this issue but all of them return only the "net" area. Best Regards, Abdallah
채택된 답변
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!