Write Matlab Code for three segment composite trapezoidal ru
     Write Matlab Code for three segment composite trapezoidal rule to solve this integration  integral_0.2^2.2 xe^x dx 
  
  Solution
function integral = cmptrap(a,b,n,f)
h = (b-a)/n;
x = [a+h:h:b-h];
integral = h/2*(2*sum(feval(f,x))+feval(f,a)+feval(f,b));
Run with
cmptrap(0.2,2.2,3,\'f\')
where ’f’ is the name of the function definition file
function y = f(t)
y = t*exp(t);
result is=10.5024

