Optimization with fminsearch and looping

1 回表示 (過去 30 日間)
Suki Sule
Suki Sule 2016 年 3 月 10 日
回答済み: Titus Edelhofer 2016 年 3 月 10 日
I have this code. t = a; s = c;
for k0 = [0.2 0.5 1 1.5]:[0.25 0.6 1.1 1.6]
[k,fval,exitflag,output] = fminsearch(@(k) suki(s, t, k), k0)
if fval <= 1
disp('Convergence has worked.')
elseif fval >= 1
disp('The convergence is not good enough')
end
end
Error message comes up as: Attempted to access k(2); index out of bounds because numel(k)=1. I need ideas on how to correct this and get the fminsearch iterations for the range of values of the initial vector k0. Thanks.
  1 件のコメント
José-Luis
José-Luis 2016 年 3 月 10 日
What does suki do?

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

回答 (1 件)

Titus Edelhofer
Titus Edelhofer 2016 年 3 月 10 日
Hi,
what do you expect
[0.2 0.5 1 1.5]:[0.25 0.6 1.1 1.6]
to be? In fact it's 0.2, and I guess your suki expects a vector for k ...
Titus

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by