error in solving numerical integral

Hi,
I want t slve a Numerical Integral fOr Leonard-johnes Potential
How can I Solve this error ?
Fun=@(x,t)(x^2*(exp(-((1/(x^12))-(1/x^6))/t))-1));
Q=integral(@(x)Fun(x,10),0,2)
Error In integral
I Also need to plot Q in different t
Do You Have Any Comments ?

 Accepted Answer

madhan ravi
madhan ravi on 17 Jan 2019
Edited: madhan ravi on 17 Jan 2019
syms t x % at the very beginning
%remove @(x,t) and replace it with matlabFunction()

More Answers (1)

Fun=@(x,t) x.^2.*(exp(-((1./(x.^12))-(1./x.^6))./t))-1
You had too many ) and you needed to vectorize. integral() always invokes the function with a vector of values rather than just a single value.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!