The idea is great. It is impossible to compute jacobian with respect to numerous variables using standard Symbolic Toolbox.
However I found that the expression x'*A*x causes an error in Matlab 2010a. I was able to correct it by writing x'*(A*x) and correcting the 'adiffadiff' case in mtimes.m file (transposition should be added to first factors).
Is there a way to allow free usage of matrix expressions (i.e. free transposition usage and maybe allow to calculate derivatives with respect to a matrix)? I haven't found any matlab library that allows of doing it with respect to vector of variable length.