First you don't need the variable w, your problem is to maximize corr(Q,S), which is a unconstrained problem in x. Second, by your problem definition, Q is a single value, and correlation between single values doesn't make much sense, so I believe what you mean by corr is that the values should be equal or Q is a vector and you forgot a summation index. Considering the second hypothesis an example of how to do it could be seen here:
S = 1:100;
c = randn(100,4);1
f = @(x,S,c)-min(min((corrcoef(S', (x*c')/sum(x) )) ));
[x,fval] = fminsearch(@(x)f(x,S,c),[1,1,1,1])
You can use this code as basis to implement your problem.