MATLAB: How to create a complex integrand composed of simpler functions for a function handle in MATLAB

complexfunctionhandleintegrandMATLAB

I would like to compose my integrand in the QUAD function (or any function that takes a function handle as an input) from a set of simpler custom functions. How do I achieve this?

Best Answer

You can create the integrand for the QUAD function from a set of simpler custom functions using anonymous function handles. The demo code below illustrates this further:
fn_1 = @(x)x.^3;
fn_2 = @(x)x.^2;
F = @(x)fn_1(x)./(1+fn_2(x));
Q = quad(F,0,2)