MATLAB: Jacobain with 3 functions

derivativejacobiansymbolicSymbolic Math Toolbox

Hello,
Can someone help me to see what is wrong with my jacobian?
I reviewed it several time byt matlab still says there is a syntax error.
Additionally, why jacobian(f,x) does not work?
f=@(x) [3*x(1) - cos(x(2)*x(3)) - 3/2;
4*x(1)^2 - 625*x(2)^2 + 2*x(3) - 1;
20*x(3)^3 + exp(-1*(x(1)*x(2))) + 9]
J=@(x) [3, -1*(x(3)*cos(x(2)*x(3))), -1*(x(2)*cos(x(2)*x(3)));
8*x(1) , 1250*x(2), 2;
-1*(x(2)exp(-x(1)*x(2))), -1*(x(1)exp(-x(1)*x(2))), 20]

Best Answer

https://in.mathworks.com/help/symbolic/jacobian.html - the function has to have symbolic arguments as mentioned in the link above , where as what you created was a function handle (@(x)).
x = sym('x',[1 3]);
syms(x) % the reason I used this is even you can access the elements of the vector x as like x1 or x(1) unlike x = sym('x',[1,3]) where you can only access the elements as x(1) but not as x1!
f= [3*x(1) - cos(x(2)*x(3)) - 3/2;
4*x(1)^2 - 625*x(2)^2 + 2*x(3) - 1;
20*x(3)^3 + exp(-1*(x(1)*x(2))) + 9]
jacobian(f,x)
if you type
>> which jacobian -all
/Applications/MATLAB_R2018b.app/toolbox/symbolic/symbolic/@sym/jacobian.m % sym method
>>
It shows that jacobian() belongs to symbolic math toolbox.