%% Basic Goal Attainment Problem
% Consider the two-objective function
% F(x) = \left [ {2 + (x - 3)^2\atop5 + x^2/ 4 }\right ].
% This function clearly minimizes F_1(x) at x = 3, attaining the value 2, and minimizes F_2 (x) at x = 0, attaining the value 5.
% Set the goal [3,6] and weight [1,1], and solve the goal attainment problem starting at x0 = 1.

fun = @(x)[2+(x-3)^2;5+x^2/4];
goal = [3,6];
weight = [1,1];
x0 = 1;
x = fgoalattain(fun,x0,goal,weight)

% Find the value of F(x) at the solution.

fun(x)

% fgoalattain achieves the goals exactly.
% Copyright 2018 The MathWorks, Inc.