%% Obtain All Minimax Outputs
% The objective functions for this example are linear plus constants. For a description and plot of the objective functions, see Compare fminimax and fminunc.
% Set the objective functions as three linear functions of the form {\rm dot}(x,v)+v_0 for three vectors v and three constants v_0.

a = [1;1];
b = [-1;1];
c = [0;-1];
a0 = 2;
b0 = -3;
c0 = 4;
fun = @(x)[x*a+a0,x*b+b0,x*c+c0];

% Find the minimax point subject to the inequality x(1) + 3*x(2) <= –4.

A = [1,3];
b = -4;
x0 = [-1,-2];

% Set options for iterative display, and obtain all solver outputs.

options = optimoptions('fminimax','Display','iter');
Aeq = []; % No other constraints
beq = [];
lb = [];
ub = [];
nonlcon = [];
[x,fval,maxfval,exitflag,output,lambda] =...
    fminimax(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options)

% Examine the returned information:
% Two objective function values are equal at the solution.
% The solver converges in 4 iterations and 19 function evaluations.
% The lambda.ineqlin value is nonzero, indicating that the linear constraint is active at the solution.
% Copyright 2018 The MathWorks, Inc.