フィルターのクリア

fminsearch error regarding matrix dimensions

1 回表示 (過去 30 日間)
MiauMiau
MiauMiau 2014 年 7 月 3 日
コメント済み: MiauMiau 2014 年 7 月 3 日
Hi
I am using fminsearch to minimize the following function:
a_d = 13.2414;
a_nd = 15.5107;
b_d = -1.4207;
b_nd = -1.9339;
Ft = 35;
funct = @(x)a_d*((2*Ft)/(x+1))+b_d+(a_nd*x*((2*Ft)/(x+1)))+b_nd;
[x,fval] = fminsearch(funct, [0, 10]);
But do get the following error:
Error using /
Matrix dimensions must agree.
Error in @(x)a_d*((2*Ft)/(x+1))+b_d+(a_nd*x*((2*Ft)/(x+1)))+b_nd
Error in fminsearch (line 191)
fv(:,1) = funfcn(x,varargin{:});
Error in Script (line 22)
[x,fval] = fminsearch(funct, [0, 10]);
What is the problem? Thanks!

採用された回答

Mischa Kim
Mischa Kim 2014 年 7 月 3 日
編集済み: Mischa Kim 2014 年 7 月 3 日
MiauMiau, the function funct has only one dependent variable, x, correct? If so this needs to be reflected in the function call for fminsearch
[x,fval] = fminsearch(funct, 0);
With your function call
[x,fval] = fminsearch(funct, [0, 10]);
you assign starting values for a 2-vector, e.g. x1 and x2.
  3 件のコメント
Mischa Kim
Mischa Kim 2014 年 7 月 3 日
Use instead
[x,fval] = fminbnd(funct,0,10)
MiauMiau
MiauMiau 2014 年 7 月 3 日
prft, thx

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParticle Swarm についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by