フィルターのクリア

Code verification for multiple nonlinear constraints

1 回表示 (過去 30 日間)
Oladunjoye
Oladunjoye 2014 年 3 月 27 日
編集済み: Oladunjoye 2014 年 3 月 27 日
Hi everyone,
I am using fmincon and I have a couple of nonlinear equality constraints. I wish to know which of the codes below is correct for the constraint.
function [c,ceq] = const(x)
c = [];
ceq(1) = x(1)'*x(1) + x(2)'*x(2) + x(3)'*x(3)+ x(4)'*x(4) + x(5)'*x(5) ...
+x(6)'*x(6) - 1;
ceq(2) = x(7)'*x(7) + x(8)'*x(8) + x(9)'*x(9)+ x(8)'*x(10) + ...
x(11)'*x(11) +x(12)'*x(12) - 1;
end
OR
function [c,ceq] = const(x)
c = [];
f1 = x(1)'*x(1) + x(2)'*x(2) + x(3)'*x(3)+ x(4)'*x(4) + x(5)'*x(5) ...
+x(6)'*x(6) - 1;
f2 = x(7)'*x(7) + x(8)'*x(8) + x(9)'*x(9)+ x(10)*x(10) + x('11)*x(11) ...
+x(12)'*x(12) - 1;
ceq = [f1,f2];
end
Which of the above codes is the correct way to write the constraints?

回答 (0 件)

カテゴリ

Help Center および File ExchangeSolver-Based Nonlinear Optimization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by