Overestimation of mean with trapz

2 ビュー (過去 30 日間)
Emily
Emily 2017 年 6 月 19 日
コメント済み: Star Strider 2017 年 6 月 19 日
Hi,
I'm using trapz(x,y) to find the mean value of a portion of a signal.
x = [0.3 0.3 0.3 0.4 0.5 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.2 1.3 1.4 1.4 1.5 1.5];
y = [14.0 15.8 15.8 16.3 19.7 23.5 25.2 27.1 28.4 29.1 30.3 30.6 30.6 30.5 30.5 30.4 30.4 30.4 30.3];
The maximum value in y is 30.6. However, trapz(x,y) = 32.3.
Why is the mean value estimated by trapz greater than the maximum value of the dataset? I thought maybe the spacing was too coarse and tried interpolating on a much finer grid, but the trapz mean still exceeded the maximum value of y.
Thanks for any help!

採用された回答

Star Strider
Star Strider 2017 年 6 月 19 日
The mean is defined as the integral of ‘y(x)’ from ‘x=a’ to ‘x=b’ divided by ’(b-a)’:
trapz_mean = trapz(x,y)/(max(x)-min(x));
trapz_mean =
26.9292
  2 件のコメント
Emily
Emily 2017 年 6 月 19 日
Thanks! I thought the division by the range was implicit.
Star Strider
Star Strider 2017 年 6 月 19 日
My pleasure!
In the mean function, it is. Calculating it using numerical (or symbolic) integration, it is not.

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

その他の回答 (0 件)

カテゴリ

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