フィルターのクリア

fmincon optimize matrices of different size

1 回表示 (過去 30 日間)
Jing Xie
Jing Xie 2021 年 10 月 8 日
コメント済み: Jing Xie 2021 年 10 月 11 日
Ciao everyone.
I am trying to use fmincon for an optimization task. And I am not sure if fmincon can do this.
For an easy example:
There is a matrix x1 (size 3*3), and there is another matrix x2(size 4*4)
The objective function is
fun = A1*(x1-A)^2*A1'+ B1*(x2-B)^2*B1'
size of A1 is 1*3
A is 3*3
B1 is 1*4
B is 4*4
so we get objective function as a scalar.
The normal approach is to reshape the x1 and x2 and put them into a single vector x for optimization.
My question is that is there a way to formulate the x as x = [x1, x2] directly as matrices of different sizes?

採用された回答

Matt J
Matt J 2021 年 10 月 8 日
編集済み: Matt J 2021 年 10 月 8 日
x1=optimvar('x1',3,3);
x2=optimvar('x2',4,4);
fun = fcn2optimexpr( @(x1,x2) A1*(x1-A)^2*A1'+ B1*(x2-B)^2*B1' ,x1,x2)
p=optimproblem('Objective',fun);
sol=solve(p)
  1 件のコメント
Jing Xie
Jing Xie 2021 年 10 月 11 日
Thanks a lot! That works!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by