登录论坛

查看完整版本 : 【求助】新手:请教这个小程序错在那里 ??(2007a中)


bulekala
2007-07-23, 17:33
新手:请教这个小程序错在那里 ??(2007a中)

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;


——————————————————
菜鸟求助!!!

xieren
2007-07-28, 22:17
不要用x(2)

NaN
2007-07-30, 00:23
对于只有函数定义的文件来说,你不能直接去运行的,就是出现这样的错误的

linlan999
2007-08-04, 09:23
http://hiphotos.baidu.com/linlan999/pic/item/9b0d62f7c7e3302a720eec8d.jpg

clongclong
2007-08-07, 14:26
对哦,:)