Getting area of selected area plot?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Is it possible to calculate the area selected with the area plot (example attached)?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/162425/image.png)
Working with area plots allows to visually confirm how accurate my selection of points are, but I don't know how to get the filled area. I know that trapz is used for data under curve calculations, but my values are negative, plus I cannot see the exact data calculated with trapz, so I cannot confirm if I use it as I think I am.
---edit
Does this do the job?
trapz(selectedArea.YData, selectedArea.YData)
0 comentarios
Respuestas (1)
Star Strider
el 25 de Abr. de 2016
That won’t, but this might:
sel_area = trapz(selectedArea.XData, selectedArea.YData);
assuming of course that ‘selectedArea.XData’ exists.
2 comentarios
Star Strider
el 26 de Abr. de 2016
My pleasure.
I’m not certain what you’re asking. The area plotted with area should reflect what trapz calculated, however I have no idea how you would verify that. (One possibility might be the polyarea function.) Also, see if the related cumtrapz function will do what you want.
Ver también
Categorías
Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!