フィルターのクリア

How to pass multiple parameters to function handle when invoke 'fmincon'

40 ビュー (過去 30 日間)
Li Yang
Li Yang 2016 年 4 月 15 日
回答済み: Walter Roberson 2016 年 4 月 15 日
Hello, I have a question when I am trying to use 'fmincon' function. The following is my objective function:
function obj = func_obj(x,a,b,c)
obj = x(1)*a + x(2)^2*b + c;
end
And I have both equality and Inequality nonlinear constraint as :
function [c,ceq] = func_con (x,a,b,c,d)
c = x(1)^2 + x(2)^2 -a^2;
ceq = (x(1)*a -x(2)*b)^2 -x(2)*b -d^2;
end
The a,b,c,d are coefficients that need to be changed during every loop, as:
for i = 1: 10
a = ....;
b = ....;
c = ....;
d = ....;
fun = @ func_obj;
nonlcon = @ func_con;
[x,val] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon);% x0,A,b ect. properly configured
end
Since I need varying coefficients in my func_obj and func_cont, and I have both equality and inequality constraints, the way shown in document doesn't seem to help for my application. Could anyone help me on how to pass a,b,c,d properly to the objective and constraint functions? Thanks a lot!

採用された回答

Walter Roberson
Walter Roberson 2016 年 4 月 15 日
fun = @(x) func_obj(x, a, b, c, d);
nonlcon = @(x) func_con(x, a, b, c, d);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by