MATLAB: Dealing with Error “Not enough Input Arguments” when using NONLCON for fmincon

fminconnon linear constraints

Hello,
I'm trying to solve a basic non linear programming problem. It involves 3 non linear inequality constraints. I'm just trying to write them in a function, but I keep getting the error "Not enough input arguments" in the function NONLCONhw6 whenever I try to run my full script. I'm very new to matlab, so I know it is probably something very simple but I am stumped. Also, I probably misused the terminology in this post and I apologize.
Here is my code:
function [c,ceq] = NONLCONhw6( x )
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
c(1) = x(1)^2 + x(2)^2 + x(3)^2 + x(4)^2 + x(1) - x(2) + x(3) - x(4) - 8;
c(2) = x(1)^2 + 2*x(2)^2 + x(3)^2 + 2*x(4)^2 - x(1) - x(4) - 10;
c(3) = 2*x(1)^2 + x(2)^2 + x(3)^2 + 2*x(1) - x(2) - x(4) - 5;
ceq = [];
end
Thank you!

Best Answer

  • Please show exactly how you run your script.
    My speculation at the moment is that when you try to indicate the non-linear constraint function in the fmincon() call, that you are coding NONLCONhw6 instead of coding @NONLCONhw6