Failure in initial objective function evaluation. FMINCON cannot continue.
Afficher commentaires plus anciens
Hi all!
i have a problem with the function Fmincon. I need a vector as a solution, if i simply put fun = @(p)-sum(log(p)); fmincom gives me only a number, then i tried to put every value of the vector as can be seen below but now i have this error message, can someone give me an advice?
fun = @(p) -(log(p(1))+log(p(2))+log(p(3))+log(p(4))+log(p(5))+log(p(6))+log(p(7))+ log(p(8))+log(p(9))+log(p(10)+log(p(11))+log(p(12))+log(p(13))+log(p(14))+log(p(15))+log(p(16))+log(p(17))));
[b, fval,exitflag,output] = fmincon(fun,0.000000000000001,w' * Matr_VarCov * w,0.005^2);
f = f + 1;
SalvaTitoliDaInvestire = ~isnan(ETF(Mese_Primo(1), :));
Index exceeds the number of array elements (1).
Error in
RiskParityOnly_Esercizio2>@(p)(log(p(1))+log(p(2))+log(p(3))+log(p(4))+log(p(5))+log(p(6))+log(p(7))+log(p(8))+log(p(9))+log(p(10)+log(p(11))+log(p(12))+log(p(13))+log(p(14))+log(p(15))+log(p(16))+log(p(17))))
(line 89)
fun = @(p) (log(p(1)) + log(p(2))+
log(p(3))+ log(p(4))+ log(p(5))+
log(p(6))+ log(p(7))+ log(p(8))+
log(p(9))+ log(p(10)+ log(p(11))+
log(p(12))+ log(p(13))+ log(p(14))+
log(p(15))+ log(p(16))+ log(p(17))));
Error in fmincon (line 562)
initVals.f =
feval(funfcn{3},X,varargin{:});
Error in RiskParityOnly_Esercizio2 (line 90)
[b, fval,exitflag,output] =
fmincon(fun,0.000000000000001,w' *
Matr_VarCov * w,0.005^2);
Caused by:
Failure in initial objective function
evaluation. FMINCON cannot continue.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Results, Reporting, and Test File Management dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!