Fmincon error not enough input arguments
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
function Variancee = VarObjective(VCVMatx, WStarSave);
Variancee = WStarSave * VCVMatx * WStarSave';
[x, fval] = fmincon('VarObjective', WStarSave', swtOther_A, swtOther_b, AeqMatx, BeqMatx, swtMinWt', swtMaxWt')
%where
WStarSave = 1 X 10 matrix of weights
swtOther_A = [ 0 0 0 0 -1 0 0 -1 0 -1 ; 0 0 0 0 1 0 0 1 0 1];
swtOther_b = [ -0.06 ; +0.40 ];
AeqMatx(1, :) = swtOther_Aeq; where this equals [ 1 1 1 1 1 1 1 1 1 1 ];
AeqMatx(2, :) = returnMatx(1, :);
AeqMatx(3, :) = [1 0 1 0 0 0 1 0 0 0];
BeqMatx(1, :) = swtOther_beq; where this equals [ 1.00 ];
BeqMatx(2, :) = ERGrid(i, 1); where this i will change into the loop
BeqMatx(3, :) = [.22];
THE ERROR WE GET IS THE FOLLOWING:
Not enough input arguments.
Error in VarObjective (line 3)
Variancee = WStarSave * VCVMatx * WStarSave';
Error in fmincon (line 552)
initVals.f = feval(funfcn{3},X,varargin{:});
Error in FEHW7 (line 205)
[x, fval] = fmincon('VarObjective', WStarSave', swtOther_A, swtOther_b, AeqMatx, BeqMatx, swtMinWt', swtMaxWt');%lb -s -inf and ub is +inf
Caused by:
Failure in initial objective function evaluation. FMINCON cannot continue.
0 commentaires
Réponses (1)
Stephan
le 4 Juin 2019
Your objective function takes 2 input arguments - by default the optimization solvers only use 1 argument, which is the vector of variables to find optimal values for. For passing extra parameters to your óbjective function via the optimization solver have a read here:
for example if your optimization variables are stored in VCVMatx use:
[x, fval] = fmincon(@(VCVMatx)VarObjective(VCVMatx, WStarSave), ...)
0 commentaires
Voir également
Catégories
En savoir plus sur Solver Outputs and Iterative Display 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!