# How do I calculate the area under a curve?

조회 수: 1(최근 30일)
SS 2020년 5월 14일
댓글: Image Analyst 2020년 5월 16일
I have a reading curve from some experimental observations. I want to calculate the area under the curve - between customized X and Y values. I want it in between X=[-0.9,+0.9] and Y=[0.3,0.45]. How can I do it? I am attaching the figure for reference.

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

### 채택된 답변

Image Analyst 2020년 5월 14일
편집: Image Analyst 2020년 5월 14일
Did you try
indexes = X >= -0.9 & X <= 0.9;
area = trapz(X(indexes), Y(indexes))
But what do you mean with those Y limits? That would just be a rectangular box under the curve.
##### 댓글 수: 2표시숨기기 이전 댓글 수: 1
Image Analyst 2020년 5월 16일
Yes, but you'd have to somehow extract the x and y out of the figure. I never do that but I know it's possible. How did the figure get made in the first place? Why do you not have the actual coordinates in your script, function, or in a mat file???

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

### 범주

Find more on Graphics Object Identification in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by