| 查看: 165 | 回复: 0 | ||
| 当前主题已经存档。 | ||
[交流]
【已解决】求教一个关于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 ] |














回复此楼