Iterative Optimization with fminsearch

조회 수: 2 (최근 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 CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by