When I run the code for the second problem, it seems something gets wrong:
Your initial point x0 is not between bounds lb and ub; FMINCON
shifted x0 to strictly satisfy the bounds.
First-order Norm of
Iter F-count f(x) Feasibility optimality step
0 43 -8.940697e-08 1.700e+00 5.428e-03
1 86 -1.469335e+00 4.701e-01 1.266e-01 2.907e+00
2 94 -1.482727e-01 5.284e-07 2.408e-01 2.803e+00
Local minimum possible. Constraints satisfied.
fmincon stopped because the gradient calculation is undefined. Constraints
are satisfied to within the selected value of the constraint tolerance.
<stopping criteria details>
ans =
yalmiptime: 1.6602
solvertime: 0.7308
info: 'Successfully solved (FMINCON)'
problem: 0
ans =
yalmiptime: NaN
solvertime: NaN
info: 'Unknown problem in solver (Turn on 'debug' in sdpsettings) (Error using barrier (line...'
problem: 9
Your initial point x0 is not between bounds lb and ub; FMINCON
shifted x0 to strictly satisfy the bounds.
ans =
yalmiptime: NaN
solvertime: NaN
info: 'Unknown problem in solver (Turn on 'debug' in sdpsettings) (Error using barrier (line...'
problem: 9