wenyukui 发表于 2006-12-4 15:23

求救,谢谢大家了,这个程序是怎么了MATLAB,函数加了引号还不行

A=[-17.7166,5.1179;50.3437,-20.9333;-99.3832,66.756;236.1567,-192.9286;-169.4007,141.9878];
b=;
x0=;
x=fmincon('((405.5574*x(3)-334.9164*x(4)+35.0546)^2+(-17.7166*x(3)+5.1179*x(4)+36.0007)^2)^(1/2)',x0,A,b)
Warning: Large-scale (trust region) method does not currently solve this type of problem,
switching to medium-scale (line search).
> In fmincon at 260
??? Error using ==> fmincon
FMINCON cannot continue because user supplied objective function failed with the following error:
Error using ==> inlineeval
Error in inline expression ==> ((405.5574*x(3)-334.9164*x(4)+35.0546)^2+(-17.7166*x(3)+5.1179*x(4)+36.0007)^2)^(1/2)
??? Error using ==> eval
Index exceeds matrix dimensions.
谢谢,很不好意思

shenyongjun 发表于 2006-12-4 22:45

你的函数中只有两个变量,却用了x(3)和x(4),因此出现“Index exceeds matrix dimensions”的警告。分别改为x(1)和x(2)后,得到了如下结果,不知是否你箱要的?
x=fmincon('((405.5574*x(1)-334.9164*x(2)+35.0546)^2+(-17.7166*x(1)+5.1179*x(2)+36.0007)^2)^(1/2)',x0,A,b)
Warning: Large-scale (trust region) method does not currently solve this type of problem,
switching to medium-scale (line search).
> In fmincon at 260
Optimization terminated: Magnitude of directional derivative in search
direction less than 2*options.TolFun and maximum constraint violation
is less than options.TolCon.
Active inequalities (to within options.TolCon = 1e-006):
lower      upper   ineqlin   ineqnonlin
                        5         

x =

    2.5212
    3.1154

wenyukui 发表于 2006-12-5 10:33

感谢

x0=;这个起始点变化为什么结果不变,它对结果有什么影响?
页: [1]
查看完整版本: 求救,谢谢大家了,这个程序是怎么了MATLAB,函数加了引号还不行