simpsons rule for integration with multivariable
7 ビュー (過去 30 日間)
古いコメントを表示
I am having trouble setting up the equation.
supposedly, I am trying to fine the integral of 0.7051*r.*T from 0.308 to 0.478
both r and T are vectors.
so far I have @f = @(r,T) 0.7051*r.*T
a = 0.308
b = 0.478
n = length(r) to be number of subdivisions
h = (0.478-0.308)/10 to be step size
The following is my approach so far I= h/3*(f(r(1),T(1))+2*sum(f(r(3:2:end-2),T(3:2:end-2)))+4*sum(f(r(2:2:end),T(2:2:end)))+f(r(end),T(end)))
I am not sure if I need to use a for loop to include all a,b,and h input or this (I) is good....
0 件のコメント
回答 (1 件)
Roger Stafford
2017 年 11 月 14 日
There is some confusion here as to what your variable of integration is to be. In the way you define ‘h’ it would appear to be some variable that varies from 0.308 to 0.478 in ten discrete steps. But how does that relate to the two vectors ‘r’ and ’T’ with their ’n’ values? You would need for 'n' to equal eleven to be compatible with the ten in the definition of ‘h’.
Also the term “+4*sum(f(r(2:2:end),T(2:2:end)))” looks incorrect. It should be “+4*sum(f(r(2:2:end-1),T(2:2:end-1)))”.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Numerical Integration and Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!