Find area bounded by self-intersecting array of data

조회 수: 3 (최근 30일)
Rchamp
Rchamp 2021년 3월 14일
답변: Nipun 2024년 6월 7일
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
darova
darova 2021년 3월 15일
Can you show on the picture are you want to calculate?

댓글을 달려면 로그인하십시오.

답변 (1개)

Nipun
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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by