I am trying to write a simple MATLAB program that will find the first chain (over 70) of consecutive nonzero values ββand return the initial value of this sequential chain.
I work with movement data from the joystick, and there are several thousand rows of data with a mixture of zeros and non-zero values ββbefore the start of the actual trial period (from subjects slightly moving the joystick to the start of the actual launch).
I need to get rid of these lines before I begin to analyze the movement from the tests.
I am sure this is a relatively simple thing, so I was hoping that someone could offer insight. Thank you in advance
EDIT: here is what I tried:
s = zeros(size(x1)); for i=2:length(x1) if(x1(i-1) ~= 0) s(i) = 1 + s(i-1); end end display(S);
for a vector x1 that has a maximum chain of 72, but I donβt know how to find the maximum chain and return its first value, so I know where to crop. I also really don't think this is the best strategy since the maximum chain in my data will be tens of thousands of values.
source share