フィルターのクリア

quad error

2 ビュー (過去 30 日間)
Melissa
Melissa 2012 年 3 月 19 日
Good Afternoon All,
I am attempting to use matlab quad on a simple constant and im getting a rather large error (the calculated value is online 25% of the actual value). Say I have f(x)=10 and wish to calculate the definite integral between 0 and 5.
Then the it will be the integral of 10 dx from 0 to 5
This leads to 10x between 0 and 5 = 10(5)-10(0)=50.
When I use matlab quad I get: >> f=10;a=0;b=5; >> x=quad(inline('f'),a,b)
x =
12.5000
Where am I going wrong with this?
Thanks,
Mel
  1 件のコメント
Sean de Wolski
Sean de Wolski 2012 年 3 月 19 日
I'd like to throw a word in for recommending against using INLINE!
doc function_handle

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

採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 3 月 19 日
out = quad(@(x)10*ones(size(x)),0,5)
OR
out = trapz([0 5],[10 10])
  1 件のコメント
Melissa
Melissa 2012 年 3 月 19 日
thanks so much trapz works perfectly!!

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

その他の回答 (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