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

조회 수: 1 (최근 30일)
Kyeongdong . 2023년 9월 26일
편집: Dyuman Joshi . 2023년 9월 27일
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?

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

### 채택된 답변

Torsten 2023년 9월 26일
이동: Torsten 님. 2023년 9월 26일
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이전 댓글 2개 표시이전 댓글 2개 숨기기
Torsten 2023년 9월 26일
편집: Torsten 님. 2023년 9월 26일
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 2023년 9월 26일
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.

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

### 카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

R2023a

### Community Treasure Hunt

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

Start Hunting!