% Here is an example using a function handle in the numerical quadrature
% function:
% **********************************************************************
%     A=quad(@sin,0,1);
%     fprintf('integral of sin(x) from 0 to pi is %12.6f\n',A);
% **********************************************************************
% Now suppose you have a function that you would like to integrate, but
% you want to maintain some flexibility in letting some parameters in the
% function to vary. For example, you would like to integrate
%    y = a2*x^2 + a1*x + a0
% If you write a function called myintegrand with x, a2, a1, and a0 as
% variables, the MATLAB function quad function handle will not be able to
% call this fucntion, as it is expecting a function of one varialbe, such
% as sin(x). One way to get around this is to use the following approach:
function I=myquad(a,b,a0,a1,a2)
I = quad(@myintegrand,a,b);
    function y=myintegrand(x)
        y = a2*x.^2 + a1*x + a0;
    end
end
% This function integrates the function specified in myintegrand but we can
% pass parameters a0,a1, and a2. 