"Matt J" wrote in message <firstname.lastname@example.org>... > > > 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.
You mentioned that the problem could be written in quadprog. In the optimization, fmincon(@(x)norm(H*x-w0)^2,w0,,,Aeq,beq,lb,,,options) w0 is a constant. If possible could you please show me how I can rewrite the problem so that it could fit the quadprog function? Thanks so much