24小时热门版块排行榜    

CyRhmU.jpeg
查看: 147  |  回复: 0
当前主题已经存档。

compiler

新虫 (小有名气)

[交流] 【已解决】求教一个关于fmincon的弱问题

目前要做关于优化的问题,和fmincon函数使用有关,但是不管我运行help里面的例子,还是网上找的例子,运行都失败,请达人帮忙指点一下吧,非常感谢。
比如help里的例子:
function f = myfun(x,a)
         f = x(1)^2 + a*x(2)^2;

and

         function [c,ceq] = mycon(x,b)
         c = b/x(1) - x(2);
         ceq = [];

    To optimize for specific values of A and B, first assign the values to the
se
    two parameters. Then create two one-argument anonymous functions that capt
ure
    the values of A and B, and call MYFUN and MYCON with two arguments. Finall
y,
pass these anonymous functions to FMINCON:

         a = 2; b = 1.5; % define parameters first
         x = fmincon(@(x)myfun(x,a),[1;2],[],[],[],[],[],[],@(x)mycon(x,b))
请高手运行一下,看是否能成功,指导一下吧!
===================================================
原来是我的软件问题,重装一下就解决了。

[ Last edited by compiler on 2010-4-9 at 07:28 ]
回复此楼
生命在于行动!
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 compiler 的主题更新
普通表情 高级回复(可上传附件)
信息提示
请填处理意见