I've got a few ugly equations to take gradients of and I'd love to get matlab to validate my work, but I'm having trouble because the equations are mixed with variable length vectors and some gnarly summations.
If I could get this to work I might be able to express my more complex formulas. Let $f(\boldsymbol{d})=\sum_{n=1}^N d_n\ln(d_n)$ where $\boldsymbol{d} \in \mathbb{R}^N$.
I've tried fixing $N$ to an arbitrary value such as $3$. I've tried converting things to vector notation. But I'm not getting anything to work.
For example:
>> d = sym('d',[3 1])
>> f(d) = symsum(d(n)*log(d(n)),n,1,3)
Error using sym/subsindex (line 737)
Invalid indexing or function definition. When defining a function, ensure that the arguments are symbolic variables and the body of the function is a SYM expression. When
indexing, the input must be numeric, logical, or ':'.
Error in sym/subsref (line 776)
R_tilde = builtin('subsref',L_tilde,Idx);
I'd love if there were a straight forward way to model the expression as I see it there rather than needing to convert it to something else (e.g. fewer chances for human error). Though I haven't gotten anything to work yet.
If I use vector notation, I'm not quite clear on what I'm getting, and I'm afraid that I won't be able to build up more complex formulas from what I see.
>> f(d) = d'*log(d)
f(d1, d2, d3) =
conj(d1)*log(d1) + conj(d2)*log(d2) + conj(d3)*log(d3)