跪求高手
这个是直接从书上copy过来的
function f=fun1(x);
f=sum(x.^2)+8;
function [g,h]=fun2(x);
g=[-x(1)^2+x(2)-x(3)^2
x(1)+x(2)^2+x(3)^3-20];
h=[-x(1)-x(2)^2+2
x(2)+2*x(3)^2-3];
options=optimset('largescale','off');
[x,y]=fmincon('fun1',rand(3,1),[],[],[],[],zeros(3,1),[], ...
'fun2', options)
不过提示function f=fun1(x);
|
Error: Function definitions are not permitted at the prompt or in scripts.
这个是直接从书上copy过来的
function f=fun1(x);
f=sum(x.^2)+8;
function [g,h]=fun2(x);
g=[-x(1)^2+x(2)-x(3)^2
x(1)+x(2)^2+x(3)^3-20];
h=[-x(1)-x(2)^2+2
x(2)+2*x(3)^2-3];
options=optimset('largescale','off');
[x,y]=fmincon('fun1',rand(3,1),[],[],[],[],zeros(3,1),[], ...
'fun2', options)
不过提示function f=fun1(x);
|
Error: Function definitions are not permitted at the prompt or in scripts.
