Find area bounded by self-intersecting array of data
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
Risposte (1)
Nipun
il 7 Giu 2024
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 Commenti
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!