Failure in initial user-supplied objective function evaluation. FMINCON cannot continue.

I am try to run the following code
A=zeros(n-1,n);
b=zeros(n-1,1);
Aeq=ones(1,n);
beq=1;
lb=zeros(n,1);
ub=ones(n,1);
x0=repmat(1/n,n,1);
fun=@(x)sum(abs(count-x));
where n is predefined and count is a vector of length n. But it gives the following error:
Error using - Matrix dimensions must agree.
Error in @(x)sum(abs(count-x(1:n)))
Error in fmincon (line 564) initVals.f = feval(funfcn{3},X,varargin{:});
Error in Training_ChiSquared_50 (line 92) x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub);
Caused by: Failure in initial user-supplied objective function evaluation. FMINCON cannot continue.
Can anyone please help me to resolve the problem ?

1 件のコメント

Torsten
Torsten 2016 年 8 月 29 日
編集済み: Torsten 2016 年 8 月 29 日
Where do you define "count" ? Is it predefined somewhere ?
The solution to your problem is very simple: x = count.
Best wishes
Torsten.

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeParallel Computing についてさらに検索

タグ

質問済み:

2016 年 8 月 29 日

編集済み:

2016 年 8 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by