%% Return quadprog Objective Function Value
% Solve a quadratic program and return both the solution and the objective function value.

H = [1,-1,1
    -1,2,-2
    1,-2,4];
f = [-7;-12;-15];
A = [1,1,1];
b = 3;
[x,fval] = quadprog(H,f,A,b)

% Check that the returned objective function value matches the value computed from the quadprog objective function definition.

fval2 = 1/2*x'*H*x + f'*x

% Copyright 2018 The MathWorks, Inc.