AUC or trapz for irregular shape that intersects itself
Afficher commentaires plus anciens
I am trying to figure out how to calculate area under the curve (AUC) for an irregular shape that intersects itself several times. The data is the length and force of a muscle that creates a thing called "work loops". The area inside of the loops are considered negative (clockwise directionality) and positive (counter-clockwise direcrtinality) work. If I could know both negative and positive work, that would be great. Although I will settle for overall work done or area inside.
I have used trapz, but that seems to not give me a consistent postive or negative number. Additionally, I cannot subset the data because the indexes needed to subset are not consecutive in some areas.
WL_1546Fa = readmatrix('~/Desktop/NAU LAB/Data/Rat/Experiments/1546/1546_WL.csv','Range','C23:C1427'); %this is where it is on my computer and hwat I need selected
WL_1546La = readmatrix('~/Desktop/NAU LAB/Data/Rat/Experiments/1546/1546_WL.csv', 'Range', 'F23:F1427'); %same here
plot(WL_1546La, WL_1546Fa); %plotting to see

trapz(WL_1546La, WL_1546Fa)
(The graph goes from left to the loop on the right and then turns back on itself to cross around 0.6 and create the other loops)
1 commentaire
Star Strider
le 3 Août 2022
Réponse acceptée
Plus de réponses (1)
Perhaps as follows?
p=polyshape(WL_1546La, WL_1546Fa);
Areas=area(regions(p))
Catégories
En savoir plus sur Numerical Integration and Differentiation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
