Matlab quad


1x32x5dx, (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); 
posted @ 2017-08-20 21:24  cxchanpin  阅读(692)  评论(0编辑  收藏  举报