Sign up ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Can someone help me generate the following symbolic summation in MATLAB? I then want to differentiate the Jacobian matrix.

$f(x) = \sum_{i=1}^{n} \sum_{j=1}^n (x_i (\Sigma x)_i - x_j (\Sigma x)_j)^2$

where $\Sigma - n \times n$ matrix and $(\Sigma x)_i$ is the i-th row of the product.

To start with,

lets say I want to generate the sum of x1+x2+x3.

I can generate x1,x2,x3 using X = sym('x',[3 1]). Then, I would expect this to work: symsum(X(k),k,1,3). But i get the following error: Indexing input must be numeric, logical or ':'.

how can I make this work ?

share|cite|improve this question
What does $(\sum x)_i$ mean? – copper.hat Jun 13 '13 at 16:50
the i-th row of the product – Shahin Jun 13 '13 at 16:51
Is there a reason you're trying to do this symbolically? While the symbolic toolbox avails you this option, it is not the best way to use MATLAB. – Arkamis Jun 13 '13 at 17:33
I want to obtain the jacobian, and n can be different each time. – Shahin Jun 13 '13 at 17:47
The $i$th row of what product? – copper.hat Jun 13 '13 at 18:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.