|
楼主 |
发表于 2008-3-25 19:45
|
显示全部楼层
重新写下问题
首先谢谢楼上的同志!
我把自己的程序先写下!
1 主程序
主要是算出a,bb,w,wh的值,然后调用youhua.m来进行优化。
2.youhua.m
function [y,f]=youhua(a,bb,w,wh)
x0=[a(2) a(3) a(4) w 1]; 初值
fun='(a(1)-bb(1)*x(5))^2+(x(1)-bb(2)*x(5))^2+(x(2)-bb(3)*x(5))^2+(x(3)-bb(4)*x(5))^2+(x(4)-wh)^2';
b=0;
A=[];
Aeq=[];
beq=[];
lb=[0 0 0 0 0];
ub=[];
[x,fv]=fmincon(fun,x0,A,b,Aeq,beq,lb,ub);
y=[a(1) x];
f=fv;
运行的错误是:
Error using ==> fmincon
FMINCON cannot continue because user supplied objective function
failed with the following error:
Error using ==> inlineeval
Error in inline expression ==> (a(1)-bb(1)*x(5))^2+(x(1)-bb(2)*x(5))^2+(x(2)-bb(3)*x(5))^2+(x(3)-bb(4)*x(5))^2+(x(4)-wh)^2
??? Undefined function or variable 'a'.
Error in ==> E:\program\train\nonliner hunting\youhua.m
On line 10 ==> [x,fv]=fmincon(fun,x0,A,b,Aeq,beq,lb,ub);
希望高手给点意见和建议! |
|