Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

not enough input arguments while using fmincon

1 vue (au cours des 30 derniers jours)
Devashish Sharma
Devashish Sharma le 25 Juil 2016
Clôturé : MATLAB Answer Bot le 20 Août 2021
function f = fun( p )
c1=100+2*p(1)+0.005*p(1)^2;
c2=200+2*p(2)+0.01*p(2)^2;
f=c1+c2;
a=[1 1];
b=450;
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 commentaire
John D'Errico
John D'Errico le 25 Juil 2016
Modifié(e) : John D'Errico le 25 Juil 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.

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by