Tweet
Below is the matlab code for simpson's 1/3rd rule :
x=[0 .2 .4 .6 .8 1]
n=6;
h=(x(6)-x(1))/5
for i=1:n
y(i)=1/(1+x(i)*x(i));
end
sum=h/3*(y(1)+y(6)+4*(y(2)+y(4))+2*(y(3)+y(5)))
Output :
>> simp
x =
0 0.2000 0.4000 0.6000 0.8000 1.0000
h =
0.2000
sum =
0.7487
Simpson's 1/3rd Rule in MATLAB
Posted by
LAHAUL SETH
~
Simpson's 1/3rd Rule in MATLAB
2012-04-25T22:17:00+05:30
LAHAUL SETH
matlab
|
Comments
Simpson's 1/3rd Rule in MATLAB
2012-04-25T22:17:00+05:30
LAHAUL SETH
matlab
|