Professional Documents
Culture Documents
Simp 13
Simp 13
n=input ('\n Enter the value of n:'); h=(xn-x0)/n; y0=exp(x0); yn=exp(xn); while(mod(n,2)~=0) n=input ('\n Enter the value of n again:'); end answ=0; for(i=1:n-1) if(mod(i,2)~=0) answ=answ+(4*(exp(x0+(i*h)))); else answ=answ+(2*(exp(x0+(i*h)))); end end answ1=(y0+yn); area=(h/3)*(answ1+answ); fprintf('\n Area is=%f',area); OUTPUT: Enter the initial limit:0 Enter the final limit:4 Enter the value of n:4 Area is=53.863846