MATLAB: Function of a variable obtained from integrating a two variable function

function from integrationmultiple variablesnumerical integration

I have a function that depends on two variables, say x and y; f(x,y). I want to integrate with respect to x only and get a new function that depends only on y; i.e., g(y) = @(y) integral(@(y)f(x,y),lim1,lim2), where lim1 and lim2 are the limits for for x. I want to use g(y) later to carry out other operations. I cannot find a way around this problem.

Best Answer

I think you've answered your own question. Why can't you create an anonymous function for g() just as you did in your post
g = @(y) integral(@(x)f(x,y),lim1,lim2)
and carry that around for reuse?