MATLAB: Numeric Derivative – problem entering df

error using mpowernumeric derivative

Hi,
I have a function (e(1)^(cos(x^2))+ln(1+x^2)…I derived it correctly to (2*x/1+x^2)-2*x*sin(x^2)*(e(1)^cos(x^2))
Then I tried to enter it to Matlab in this form:
df=(2*x./(1+x.^2))-(2*x.*sin(x.^2)*exp(1)^(cos(x.^2)))
But I am still having this error: Error using ==> mpower Inputs must be a scalar and a square matrix. To compute elementwise POWER, use POWER (.^) instead.
I really don't know where else I have to put the dots…
Can somebody fix this expression, please ??
Thanks a lot

Best Answer

df=2*x./(1+x.^2)-2*x.*sin(x.^2).*exp(1).^cos(x.^2)