MATLAB Answers

Can someone explain why I am getting the error "Not enough input arguments (line 2)"?

20 views (last 30 days)
Viktor Zankov
Viktor Zankov on 24 Jan 2021
Answered: Stephan on 24 Jan 2021
function f = fun( x )
f = 4./x(1)+9./x(2)+(x(1)+x(2));
end
function [ c,cequ ] = mycon( x )
c=[-x(1);
-x(2);
x(1)+x(2)-4];
cequ=[];
end
function myfun
x0=[1;1];
[x,f]=fmincon(@fun,x0,[],[],[],[],[],[],@mycon)
z=peaks;
surf(z);
end

Answers (1)

Stephan
Stephan on 24 Jan 2021
x0=[1;1];
[x,f]=fmincon(@fun,x0,[],[],[],[],[],[],@mycon)
z=peaks;
surf(z);
function f = fun( x )
f = 4./x(1)+9./x(2)+(x(1)+x(2));
end
function [ c,cequ ] = mycon( x )
c=[-x(1);
-x(2);
x(1)+x(2)-4];
cequ=[];
end

Community Treasure Hunt

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

Start Hunting!

Translated by