Hi All,
I am trying to solve a simple fmincon problem and keep hitting the same error message:
Error using funhw2q1Too many input arguments.Error in fmincon (line 552) initVals.f = feval(funfcn{3},X,varargin{:});Error in HW2Q1solution (line 13) xopt(i) = fmincon('funhw2q1', x0, [], [], [], [], LB, UB, 'const_hw2q1', [], j);Caused by: Failure in initial objective function evaluation. FMINCON cannot continue.
——————————————————————————————————–
Here is my main function:
x0 = [0 0]; LB = [-5 -5]; UB = [7 7];i = 1;for j = 0:0.01:1 xopt(i) = fmincon('funhw2q1', x0, [], [], [], [], LB, UB, 'const_hw2q1', [], j); solution(j) = x(1)^2 + 10 * x(2) - 3 * X(1) * X(2); i = i + 1;end
——————————————————————————————————-
here is 'funhw2q1':
function f = funhw2q1(x)f = x(1)^2 + 10 * x(2)^2 - 3 * x(1) * x(2);end
———————————————————————————————————-
and here is the constraints function if that makes any sense in this problem:
function [c, Ceq] = const_hw2q1(x)c(1) = 2*x(1)+x(2) - 4;c(2) = x(1) + x(2) + 5;Ceq = [];
Please help. I know it is a very simple problem but I ran out of options.
Best Answer