필터 지우기
필터 지우기

Numerical integration using Simpsons

조회 수: 1 (최근 30일)
mohammed shapique
mohammed shapique 2020년 11월 10일
답변: Alan Stevens 2020년 11월 10일
Simpsons numerical integration to evalaute
lambda=0.0:0.1:1
mu2=0.5;
gamma2=0.7;
zeta=0.1;
a=0;%lower limit
b=1;%upper limit
n=10;%number of sub-intervals
h=(b-a)/n;
f3=@(x,p)(x.^((mu2/zeta)-1)).*((1-x).^((gamma2./zeta))).*(exp(-(lambda(p).*x)./zeta));
for p = 1:numel(lambda)
for k=1:n
x(k)=a+k*h;
y(k)=f3(x(k),p);
end
so=0;se=0;
for k=1:n-1
if rem(k,2)==1
so=so+y(k);%sum of odd terms
else
se=se+y(k); %sum of even terms
end
end
I3(p)=h./3.*(f3(a,p)+f3(b,p)+4.*so+2.*se)
end
For 11 values of lambda, i am getting 61 solutions. Please help me to find the error.

채택된 답변

Alan Stevens
Alan Stevens 2020년 11월 10일
I just get 11 values for I3, running your code!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by