I may be wrong but I don't think my problem can be written in a form of quadprog because I cannot modify "x" in the quadratic optimization function. ================
It can be written in the form required by quadprog, but you're right that lsqlin looks more directly applicable.
I could potentially use lsqlin but here again it doesn't work I get a NaN value and it says "Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN. " > > Alan kindly suggested to use 'Hessian','lbfgs' with the fmincon and this time it works but when I check the optimized variables they all have the same value. Don't get me wrong I am not an expert in optimization, but it is weird to have the same value for the optimized variables? Shall I relax the tolerance? or do you think that it may be a problem inherent to my optimization function? ===============
From the output of LSQLIN, it sounds like you have bad data. As for all the variables having the same value, that depends on w0 and other problem data. It should be easy enough to check whether optimality conditions are satisfied at the solution given.