Failure in initial objective function evaluation. FMINCON cannot continue

6 Ansichten (letzte 30 Tage)
for i=1:3
P_j(:,i) = fmincon(@(X)( X*(k_integ(:,:)*X.') ), P_j0(:,i), [], [], A, Beq(:,i) );
end
I have P_j0 as 52x3, A as 37x52, Beq as 37x3, k_integ as 52x52 (3 for x, y and z) When using fmincon for each i, I get
Error using * Inner matrix dimensions must agree.
Caused by: Failure in initial objective function evaluation. FMINCON cannot continue.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 3 Jun. 2018
P_j0(:,i) is 52 x 1 and will become X in the anonymous function. You .' it into being 1 x 52. So you have (52 x 1) * (52 x 52) * (1 x 52) which is not valid matrix multiplication.
You can pass in P_j0(:,i).' to be passing in 1 x 52, which would get you (1 x 52) * (52 x 52) * (52 x 1) which would produce 1 x 1
  1 Kommentar
Lokesh Rakawat
Lokesh Rakawat am 4 Jun. 2018
Thanks @walter
I don't know how I made such silly mistake of simple matrix multiplication.
Thanks a lot.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Operators and Elementary Operations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by