フィルターのクリア

Getting area of selected area plot?

1 回表示 (過去 30 日間)
IJ
IJ 2016 年 4 月 25 日
コメント済み: Star Strider 2016 年 4 月 26 日
Is it possible to calculate the area selected with the area plot (example attached)?
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)

回答 (1 件)

Star Strider
Star Strider 2016 年 4 月 25 日
That won’t, but this might:
sel_area = trapz(selectedArea.XData, selectedArea.YData);
assuming of course that ‘selectedArea.XData’ exists.
  2 件のコメント
IJ
IJ 2016 年 4 月 26 日
XData and YData are properties of area.
Great, thanks! Do you know how I can plot area from trapz-calculated data? So, the other way around.
For example, if I wanted to confirm whether I calculated the correct selection. If I use the same y values and plot with area(), will it always reflect what trapz() calculated?
Star Strider
Star Strider 2016 年 4 月 26 日
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.

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

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by