minimizing a function with matrix output

4 vues (au cours des 30 derniers jours)
Mei Li
Mei Li le 16 Fév 2014
Commenté : Mei Li le 16 Fév 2014
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!

Réponse acceptée

Jos (10584)
Jos (10584) le 16 Fév 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 commentaire
Mei Li
Mei Li le 16 Fév 2014
I made some change to your solution and it works. Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by