minimizing a function with matrix output

4 views (last 30 days)
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!

Accepted Answer

Jos (10584)
Jos (10584) on 16 Feb 2014
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 Comment
Mei Li
Mei Li on 16 Feb 2014
I made some change to your solution and it works. Thank you!

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!