N=10; L=1; dx=L/N; x=[ dx/2: dx :1-dx/2]; f=x.^2; I=sum(f)*dx figure plot( x,f )