Im trying to run through total Force which is a 921×1 Double and check if the next value in that array is larger or greater if larger i want to subtract 0.01 from c and if smaller I want to add 0.01 to c and c starts at zero. Why does it exceed the index? Any Help would be greatly Appreciated Thanks!

`for j = 1:length(TotalForce) if j <= length(TotalForce) if TotalForce(j) >= TotalForce(j+1) c = c + 0.01 ; elseif TotalForce(j) <= TotalForce(j+1) c = c - 0.01 ; end endend`

## Best Answer