# How do I calculate the area of ​​the graph area below the baseline? (matrix plot)

1 vue (au cours des 30 derniers jours)
Kyeongdong le 26 Sep 2023
Modifié(e) : Dyuman Joshi le 27 Sep 2023
Hello
I am a beginner who just started using Matlab.
I'm looking for a way to calculate the area below the baseline in a plot like the following.
I found several ways, but it is not a continuous function, so I am not sure how to solve it, so I am leaving my question here.
The plot was drawn with the following data.
X=[0 3.343500262 4.294170234 5.636154451 7.48743621 9.469759289 10.41901651 12.15558769 12.89110736 14.77076471 16.68885991 18.26626223 18.97234208 19.58596993 20.22027814 20.94334446 21.63233231 22.00504135 23.22534155 24.21344918 25.48740811 27.35688815 30.78198827
]
Y=[216.446 216.581 216.128 216.245 215.729 214.654 214.457 213.028 212.781 212.765 212.698 212.627 212.575 212.544 212.497 212.45 212.595 212.811 213.995 214.146 214.333 216.285 216.269
]
Baseline = [212.45:0.01:216.581]
Is there a way to calculate it?
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Torsten le 26 Sep 2023
Déplacé(e) : Torsten le 26 Sep 2023
Your X-vector has two elements more than your Y-vector. After you have corrected this, you could use
idx = find(Y<=214.5);
value = trapz(X(idx),214.5-Y(idx))
##### 4 commentairesAfficher 2 commentaires plus anciensMasquer 2 commentaires plus anciens
Torsten le 26 Sep 2023
Modifié(e) : Torsten le 26 Sep 2023
What does the area under the baseline has to do with the plot command ?
To use an arbitrary baseline, replace the value 214.5 in the two lines of code by the y-value of the baseline in question. Or is the baseline not necessarily parallel to the X-axis ?
Kyeongdong le 26 Sep 2023
Yes, baseline is a line parallel to the X-axis.
The plot command was written simply to see the X and Y data visually. Exactly, I wanted to calculate the area between the baseline and the plot.

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

R2023a

### Community Treasure Hunt

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

Start Hunting!

Translated by