主题:matlab2007a
function f=myfun(x,a1)
f=x(1)^2 + a1*x(2)^2;
function [c,ceq] = mycon(x,a2)
c=a2/x(1) - x(2);
ceq =[];
a1=2; a2=1.5; % define parameters first
options=optimset('LargeScale','off'); % run medium-scale algorithm
x=fmincon(@(x)myfun(x,a1),[1;2],[],[],[],[],[],[],@(x)mycon(x,a2),options)[em10][em10][em10][em10]
%%%%%%
错误提示为:
??? Input argument "x" is undefined.
Error in ==> myfun at 2
f=x(1)^2 + a1*x(2)^2;
__________________________________
菜鸟求助!!
f=x(1)^2 + a1*x(2)^2;
function [c,ceq] = mycon(x,a2)
c=a2/x(1) - x(2);
ceq =[];
a1=2; a2=1.5; % define parameters first
options=optimset('LargeScale','off'); % run medium-scale algorithm
x=fmincon(@(x)myfun(x,a1),[1;2],[],[],[],[],[],[],@(x)mycon(x,a2),options)[em10][em10][em10][em10]
%%%%%%
错误提示为:
??? Input argument "x" is undefined.
Error in ==> myfun at 2
f=x(1)^2 + a1*x(2)^2;
__________________________________
菜鸟求助!!