フィルターのクリア

fmincon error in matlab

1 回表示 (過去 30 日間)
divya
divya 2016 年 2 月 18 日
編集済み: Walter Roberson 2016 年 2 月 18 日
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);
>>

回答 (1 件)

Brendan Hamm
Brendan Hamm 2016 年 2 月 18 日
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?

カテゴリ

Help Center および File ExchangeSystems of Nonlinear Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by