-4

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
cryptex
  • 7
  • 5

1 Answers1

1

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

ocstl
  • 520
  • 1
  • 3
  • 7