MATLAB: Error using ^ One argument must be a square matrix and the other must be a scalar. Use POWER (.^) for elementwise power.

error

My code is:
func = @(x) 5*exp(-0.5*x) + 2*exp(0.15*x)*(9 + 5*...
(cos(0.4*x))^2);
integ = integral(func,0,10);
fprintf('The integral is equal to %1.6f\n',integ);
and it shows:
Error using ^
One argument must be a square matrix and the other must be a
scalar. Use POWER (.^) for elementwise power.
Error in
A4P1a>@(x)5*exp(-0.5*x)+2*exp(0.15*x)*(9+5*(cos(0.4*x))^2)
Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);
Error in integralCalc/vadapt (line 132)
[q,errbnd] =
iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
Error in A4P1a (line 4)
integ = integral(func,0,10);
when I run it. Please help

Best Answer

integ = integral(str2func(vectorize(func)),0,10)