Not enough input arguments driving me crazy - help?

Hi, new to matlab here and having a torrid time of it. Checked the other threads and yet I remain confused. Any help would be greatly appreciated!
Trying to run this code
=================================
function f = objfun(x)
f = -x(1) * x(2) * x(3);
A = [-1 -2 -2; ...
1 2 2];
b = [0;72];
x0 = [10;10;10];
[x,fval] = fmincon(@objfun,x0,A,b);
====================================
and it returns an error in line 2 not enough input arguments
Can anybody explain what is going on here?

 채택된 답변

Youssef  Khmou
Youssef Khmou 2013년 4월 9일

0 개 추천

hi,
i am not sure what are you trying to do, but try this partial code in the workspace :
objfun=@(x) x(1)*x(2)*x(3)
A = [-1 -2 -2;1 2 2];
b = [0;72];
x0 = [10;10;10];
[x,fval] = fmincon(objfun,x0,A,b)

댓글 수: 3

Shaun Joseph
Shaun Joseph 2013년 4월 10일
편집: Shaun Joseph 2013년 4월 10일
Hi Youssef,
I am trying to work through an example using fmincon
This code you provided works(thanks!)
hi,
because there are no inputs in the line :
[x,fval] = fmincon(@objfun,x0,A,b);
as you described the function to accept an input x, that produced the error .
I don't follow...as far as I could tell...the only difference is the extra @ sign, i have the same inputs as your code (x0,A,b)
I'm trying to run code from an m.file having said that, using your code from an m file does not work

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by