MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB混合编程] 求助:Matlab 6.5 'constr' 参数如何调用? (https://www.labfans.com/bbs/showthread.php?t=9115)

heartbridge 2009-06-30 21:38

求助:Matlab 6.5 'constr' 参数如何调用?
 
Optimization toolbox 中的 constr 函数, 我查帮助如下:
X=CONSTR('FUN',X,OPTIONS,VLB,VUB,'GRADFUN',P1,P2,...)
我的函数无导数表达式,所以没有GRADFUN,我正确编写 fun, 输入
X=CONSTR('FUN',X,OPTIONS,VLB,VUB,P1,P2,...)报错。 举例如下:
fun.m:
function [f,g]=fun(x,a)

f=a.*x(1);

g(1)=-x(1);


输入
a=1;
x0=[1];
opt(1)=1;
x=constr('fun(x,a0)',x0,opt,a):confused::confused:
结果:
> In C:\MATLAB6p5\toolbox\optim\constr.m at line 55
??? Error using ==> constr
Objective/constraint expression not properly defined.

heartbridge 2009-07-01 00:53

回复: 求助:Matlab 6.5 'constr' 参数如何调用?
 
大家帮帮忙阿,多谢了!


所有时间均为北京时间。现在的时间是 12:35

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.