I would like to calculate an integral whereas the integrand is a separate external function. Consider as an example that I have in my main script:
N=5; I = integral(fn,0,Inf,'RelTol',1e-8,'AbsTol',1e-13)
Where N is a parameter of the integrand that appears in the separate function named: fn.m that has the following form:
function FUN= fn(x) FUN=@(x) (x.^N).*exp(-x).*sin(x) end
But when I do this I see the following error:
Undefined function or variable 'N'.
How can I help Matlab take this external parameter into the integrand function?
Best Answer