I just get 11 values for I3, running your code!
Numerical integration using Simpsons
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
更多回答(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!