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

2 Ansichten (letzte 30 Tage)
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

Antworten (1)

Stephan
Stephan am 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

Kategorien

Mehr zu Software Development Tools finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by