Take my code for example:
n = 8;
syms f(x) distsq(x)
P = zeros(1,n)+0.1;
f(X) = sqrt(sum(X));
distsq(X) = sum((X-P(1:end-1)).^2) + (f-P(end)).^2;
grad_distsq = jacobian(distsq,X);
equations = grad_distsq == 0;
bounds = X > 0;
bounds = [bounds X<1];
equations = [equations bounds];
S = solve(equations,X);
The code runs fine, but I have variables and it's troublesome to do operations with the solution structure S, which has fields.
How should I remove dynamic names from the code?