-4
$\begingroup$

Can someone please help me out with this loop over here? Matlab simple refuses to consider the for o=k:k-20 statement inside the if statement. :pullingmyhair:

if d(k)<=-1.5 || d(k) >=1.5
    k
    tab=tab+1
    6

    for o=k:k-20  
        5
        if abs(d(o))<abs(d(o-1))
        bench_value=o;
        break;
        end
    end
.
.
.
.
.
end
$\endgroup$

closed as off-topic by Louis Marascio, Quantopik, Bob Jansen May 25 '15 at 15:34

  • This question does not appear to be about quantitative finance within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 6
    $\begingroup$ Wrong site. Try stackoverflow? $\endgroup$ – Louis Marascio May 25 '15 at 13:51
  • $\begingroup$ I'm voting to close this question as off-topic because it would better fit on StackOverflow (but I didn't migrate because it's answered already). $\endgroup$ – Bob Jansen May 25 '15 at 15:34
1
$\begingroup$

You're looping from k to k-20 by +1 steps. Try with o = k:-1:-20.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.