fmincon error in matlab
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
i need help to solve this ?
partial code is :
%Initial Guess for parameters
P01 = [.2;.4;.04;.1;.02;2];
LB = [0;0;0;0;0;.001]; % Lower Bounds
UB = [.6;.6;.6; .6;.6;inf]; % Upper Bounds
options = optimoptions(@fmincon,'Algorithm','interior-point','Display','off');
% x = fmincon(@(x)x,1,[],[],[],[],0,[],[],options)
[P,sse] =fmincon(@(resid)resid,P01,[],[],[],[],LB,UB,[],options);
% Compare to original
[tpost1,Xpost1] =ode23s(@state,tdata,[y0;x20;x30;zeros(18,1)],[],P(1),P(2),P(3),P(4),P(5),P(6));
error is
Error using fmincon (line 607)
User supplied objective function must return a
scalar value.
Error in soren (line 27)
[P,sse]
=fmincon(@(resid)resid,P01,[],[],[],[],LB,UB,[],options);
>>
0 commentaires
Réponses (1)
Brendan Hamm
le 18 Fév 2016
Your objective function must return a scalar value but yours is returning a vector as your vector of design variables is a vector; the unchanged input. Consider your objective:
>> Objective = @(resid) resid; % Takes an input and returns it as the output.
>> Objective(1)
ans =
1
>> Objective([.2;.4;.04;.1;.02;2])
ans =
0.2000
0.4000
0.0400
0.1000
0.0200
2.0000
What is it you are truly trying to minimize? The norm of the vector perhaps?
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!