Matlab quad

来源:互联网 发布:淘宝网牛仔背带裙 编辑:程序博客网 时间:2024/05/17 16:45


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 handleF:

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