How do I calculate the area under a curve?

4 ビュー (過去 30 日間)
SS
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
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 件のコメント
SS
SS 2020 年 5 月 16 日
編集済み: SS 2020 年 5 月 16 日
Thanks for your reply. I have enclosed that graph just an example. My experimental system gives some reading curve which can also be imported to MATLAB (as a fig file). I don't have specific X and Y coordinates (data points).
How is it possible to calculate the area under the curve of an already existing figure?
Image Analyst
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???

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeModeling についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by