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

2 vues (au cours des 30 derniers jours)
Viktor Zankov
Viktor Zankov le 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

Réponses (1)

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

Catégories

En savoir plus sur Software Development Tools dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by