How to call a function in fmincon

12 ビュー (過去 30 日間)
Fred
Fred 2012 年 10 月 15 日
I have function named LL in a script named LL.m this fuction is like this
function param1=LL(u1, u2, x) param1=-sum(log((exp(-((-log(u1)).^x %+sum other stuff part continues end
u1 and u2 are 40*1 vectors of data so x is the only variable how can I call this in fmincon? I wrote it like this but it did not work
[Teta, LL] = fmincon(@(x)LL,1.5,1,10000) or [Teta, LL] = fmincon(LL,1.5,1,10000)
Thank you

採用された回答

Alan Weiss
Alan Weiss 2012 年 10 月 15 日
Just a slight change:
fun = @(x)LL(u1, u2, x)
[Teta, LL] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub)
If you don't have linear constraints, set A, b, Aeq, beq equal to []. See the documentation on how to set bounds.
Alan Weiss
MATLAB mathematical toolbox documentation

その他の回答 (1 件)

Fred
Fred 2012 年 10 月 15 日
Thank you

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by