MATLAB: How to count the number of times a specific value appears within a range in a 1D vector

countindex

Given a 1D vector, x, that has 600000 elements, how can I count the number of times the value 1 appears after the 150th position (excluding 150)?

Best Answer

  • sum(x(151:end) == 1)