minimizing a function with matrix output

4 ビュー (過去 30 日間)
Mei Li
Mei Li 2014 年 2 月 16 日
コメント済み: Mei Li 2014 年 2 月 16 日
Dear all, I have this function:
function f=obj(C1,C2,H12,H21,F1,F2)
f=norm(H12*F2-C1*C1'*H12*F2)^2+norm(H21*F1-C2*C2'*H21*F1)^2;
H12 and H21 are 3x3 matrix, F1 and F2 are 3x1 matrix. I want to minimize the function to find C1 and C2, but C1 and C2 should be a 3x1 matrix. I tried fminsearch and other function but as I read in the "help", it only results in scalar. Do you have any idea to minimize this function to get matrix result?
Thank you!

採用された回答

Jos (10584)
Jos (10584) 2014 年 2 月 16 日
You can define an error function that you minimise with fminsearch. The function obj and the arguments H12, H21, F1 and F2 should be defined beforehand. The free parameters C1 and C2 are put together in a single free parameter P. The error function errfun should return a scalar.
ErrorFun = @(P) obj(P(:,1), P(:,2), H12, H21, F1, F2)
Pinit = rand(3,2) ; % or maybe there are better initial estimates for C1 and C2?
Pout = fminsearch(ErrorFun, Pinit)
C1 = Pout(:,1)
C2 = Pout(:,2)
  1 件のコメント
Mei Li
Mei Li 2014 年 2 月 16 日
I made some change to your solution and it works. Thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by