In matlab, I must compute the symbolic gradient of a function f(x)
with x
a vector of dimension 5.
x=sym('x',[1,2,3,4,5]);
c=[1 2 4 3 5 3 4 5 4 3 4 34 5 6];
d=[1 0 1 0 0 1 1 1 0 0 0 1 0 1];
f =@(x) sum(-0.5*log(x(1))+x(1)*0.5*(x(2+d)/x(1)-c).^2-log(exp(x(2+d).*c+x(4+d))./(exp(x(2)*c+x(4))+exp(x(3)*c+x(5)))))
grad_f=gradient(f)
The message of error is :
Undefined operator '.'' for input arguments of type 'function_handle'.
Error in gradient>parse_inputs (line 146) f = f.';
Error in gradient (line 48) [f,ndim,loc,rflag] = parse_inputs(f,varargin);
Do you know where is the error?