MATLAB: Numeircal integral with external function and external parameter

function definitionintegralintegration

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

EDITED
N = 5;
F = fn(x,N); % function call
I = integral(F,0,Inf,'RelTol',1e-8,'AbsTol',1e-13)
function FUN = fn(x,N) % function definition
FUN = @(x) (x.^N).*exp(-x).*sin(x);
end
Gives:
I =
-15.0000