필터 지우기
필터 지우기

simpsons rule for integration with multivariable

조회 수: 7 (최근 30일)
darlene yen
darlene yen 2017년 11월 14일
답변: Roger Stafford 2017년 11월 14일
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....

답변 (1개)

Roger Stafford
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)))”.

카테고리

Help CenterFile 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!

Translated by