1x3−2x−5dx,
(from 0 to 1)

write a function myfun that computes theintegrand:

function y = myfun(x)
y = 1./(x.^3-2*x-5);

Then pass @myfun, a function handle to myfun,to
quad
, along with the limits of integration, 0 to 2:

Q = quad(@myfun,0,2)

Q =

   -0.4605

Alternatively, you can pass the integrand to quad asan anonymous function handle
F:

F = @(x)1./(x.^3-2*x-5);
Q = quad(F,0,2);
05-11 22:14