simpsons rule for integration with multivariable

11 Ansichten (letzte 30 Tage)
darlene yen
darlene yen am 14 Nov. 2017
Beantwortet: Roger Stafford am 14 Nov. 2017
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....

Antworten (1)

Roger Stafford
Roger Stafford am 14 Nov. 2017
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)))”.

Kategorien

Mehr zu Numerical Integration and Differential Equations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by