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 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