Sie sind auf Seite 1von 1

PROGRAM ON TRAPEZOIDAL RULE: clc; x0=input('\n Enter the initial limit:'); xn=input('\n Enter the final limit:'); n=input

('\n Enter the value of n:'); h=(xn-x0)/n; y0=(4*x0)+2; yn=(4*xn)+2; answ=0; for(i=1:n-1) answ=answ+(2*(4*(x0+(i*h))+2)); end answ1=(y0+yn); area=(h/2)*(answ1+answ); fprintf('\n Area is=%f',area); OUTPUT: Enter the initial limit:1 Enter the final limit:4 Enter the value of n:6 Area is=36.000000

Das könnte Ihnen auch gefallen