I have a function which depend on a parameter of an integral, like the following one
g(c) = integral(x^2 + c*x + 1)
where the integration range is [0,1] and the integration variable is x. In matlab this function can be defined as a multiple anonymous function
g = @(c) (integral(@(x) (x.^2 + c*x + 1),0,1));
Now, what I need to do is to integrate a function of g(c), let's say the fourth power, over c in the same range [0,1]. Hence I wrote the code
I = integral(@(c) g(c).^4,0,1)
but it doesn't work and the reason seems to be the inner product 'c*x'. Indeed I have got the same error even if I simply do the integral of g: I = integral(g,0,1) I can simply sample the c axis and use trapz routine instead of integral or implement other quadrature schemes, but still I would like to figure out why it does not work in this way and if I can overcome the problem. Any suggestion?