Iterative Optimization with fminsearch

1 回表示 (過去 30 日間)
Suki Sule
Suki Sule 2016 年 3 月 10 日
コメント済み: Titus Edelhofer 2016 年 3 月 10 日
I have 2 time series data s and t. I have a function Error code:
function Error = Output (s,t,k) error = s*k(1)*k(2)*k(3)*k(4)-t; Error = sum(error^2); end
I have initial k, k0 = [a b c d e f]. So 6 parameters to vary. I want to create a loop that will keep fminsearch running for a range of values of k. That is, from k0 = [a0 b0 c0 d0 e0 f0] to k0 = [an bn cn dn en fn]. I also want to put different intialval:step:final value for each of a,b,c,d,e,f. So let a be from 1 to 5 with step of 1, b from 0.1 to 0.5 with step of 0.1 etc If the value of fval is less or equal to 1, I want the iteration or loop to end, otherwise the loop should continue to the end. This is the code I wrote so far and the error it gives me: 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 The error it gives is: Attempted to access k(2); index out of bounds because numel(k)=1.
Can anyone help me please in implementing this?
  1 件のコメント
Titus Edelhofer
Titus Edelhofer 2016 年 3 月 10 日
Hi Suki,
is this the same question as question?
Titus

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

回答 (0 件)

カテゴリ

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