Do you really just have a single vector decision variable, of length, n? If so, your last constraint looks a little strange, as the variable is indexed by i even though it looks like a matrix-vector multiplication.
If there is a single decision variable of length n, you could program the objective function by brute force, presuming all elements of S are non-negative.
Obj = 0;
for i=1:n, for j=1:n, Obj = Obj + (d(i)-d(j))^2*S(i,j); end, end
Then add your constraints. Perhaps you can vectorize this code, but that is not necessary.
If this is not correct, you need to make clear what your optimization problem is, including all dimensions of variables and constraints…