%% Return the Objective Function Value
% Calculate the solution and objective function value for a simple linear program.
% The inequality constraints are
%  x(1) + x(2) \le 2
% x(1) + x(2)/4 \le 1
% x(1) - x(2) \le 2
% -x(1)/4 - x(2) \le 1
% -x(1) - x(2) \le -1
% -x(1) + x(2) \le 2.

A = [1 1
    1 1/4
    1 -1
    -1/4 -1
    -1 -1
    -1 1];

b = [2 1 2 1 -1 2];

%
% The objective function is -x(1) - x(2)/3.

f = [-1 -1/3];

%
% Solve the problem and return the objective function value.

[x,fval] = linprog(f,A,b)

% Copyright 2015 The MathWorks, Inc.