Find area bounded by self-intersecting array of data
조회 수: 3 (최근 30일)
이전 댓글 표시
I'm trying to find work from a PV diagram, thus I need to find the area bounded by my curve created by an array of data. Specifically, I need to find the area of the top enclosed curve, minus the area of the bottom enclosed curve. See the attached picture for more. I've tried using this function to find intersections of my data in order to split up the top and bottom enclosed curves but it returns ~110 intersections. I have also tried using polyarea but its giving me a result that is obviosly untrue (4*10^3), and I can't find a way for it to visually show me what area it is using in its calculations. Could anyone help me with this? Thanks!
답변 (1개)
Nipun
2024년 6월 7일
Hi Rchamp,
I understand that you want to find the area bounded by your curve from a PV diagram, specifically the area of the top enclosed curve minus the area of the bottom enclosed curve. Here's an approach using MATLAB:
% Assuming your data is in x and y vectors
x = ...; % your x data
y = ...; % your y data
% Find the intersections of the curves
[xa, ya] = intersections(x, y);
% Split the data into two separate curves
topCurveX = x(x <= xa(1));
topCurveY = y(x <= xa(1));
bottomCurveX = x(x >= xa(2));
bottomCurveY = y(x >= xa(2));
% Calculate the areas
areaTop = trapz(topCurveX, topCurveY);
areaBottom = trapz(bottomCurveX, bottomCurveY);
% Calculate the enclosed area
enclosedArea = areaTop - areaBottom;
% Display the result
disp(['Enclosed Area: ', num2str(enclosedArea)]);
For finding intersections, you can use this function from MathWorks MATLAB File Exchange: https://www.mathworks.com/matlabcentral/fileexchange/13351-fast-and-robust-self-intersections
Hope this helps.
Regards,
Nipun
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!