MATLAB: Symbolic Math Error using diff

symbolic mathSymbolic Math Toolbox

Hi All,
I was wondering why it is not possible to do the following
x = sym('x',[2 1]); A = sym('A',[2 2]);
diff(x'*A*x,'x')
ans = 0
Is there an alternative method to preform this differentiation?
Thanks

Best Answer

Dear Carlas, you can try something like this:
x = sym('x%d',[2 1]);
A = sym('A%d%d',[2 2]);
x1 = diff(x' * A * x, x(1));
x2 = diff(x' * A * x, x(2));
I hope it helps. Good luck!