% Syntax: opt_toolbox_qp_2

y=[ 0  0.74  -0.8  1.97  -1.09 ]';
u=[ 0.33  -0.12  0.8  -0.07 ]';
Y=y(2:5);
Phi=[-y(1:4) u];
H=2*Phi'*Phi;
c=-2*Phi'*Y;
lb=[-0.99 -Inf]';
ub=[0.99 Inf];
x0=[0 0]';
options=optimoptions('quadprog','Algorithm','active-set');
             % Select the active-set algorithm
[x,fval,exitflag]=quadprog(H,c,[],[],[],[],lb,ub,x0,options)
energy=0.5*x'*H*x+c'*x+Y'*Y
