This question is closed. Reopen it to edit or answer.

not enough input arguments while using fmincon

1 view (last 30 days)
Devashish Sharma
Devashish Sharma on 25 Jul 2016
Closed: MATLAB Answer Bot on 20 Aug 2021
function f = fun( p )
a=[1 1];
x0=[2; 3];
[p funval]=fmincon(@fun,x0,a,b)
when i run this it says error in line 2 not enough arguments please help
  1 Comment
John D'Errico
John D'Errico on 25 Jul 2016
Read the help docs for fmincon. LOOK AT THE EXAMPLES. In there you will see how to call fmincon.
In the case you have tried, the function that you pass into fmincon then tries to call itself.
Worse, you then say that you tried to run it. You cannot use run on a function.
It is time to learn what a function is, and how that is different from a script m-file.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!