# MATLAB: How to find multiple times in one array the first index of 25 samples exceeding the threshold

consecutiveindexthreshold

So, I am working with a binairy variable. To identify the onset of a muscle the binairy variable needs to be '1' for at least 25 samples consecutive.
it sometimes occures that the variable is '1' for 40 samples than '0' for few samples and then '1' again for more than 25 samples. Now i have MATLAB code where i can identify the index for the first string of 25 samples '1', but I can not seem to get the first index for the second string of 25 or more samples '1'.
is there anybody that can help me out?
here is my matlab code so far(including creating the binairy variable):
%create binairy variableex_threshold_preDC2= prestroke1(:,3) > threshold(:,3);%initialising ones_window = ones(1,25); for idx = 1:length(ex_threshold_preDC2)-25         window_preDC2 = ex_threshold_preDC2(idx:idx+24);                  if window_preDC2==ones_window             index_preDC2 = idx;                   endend 
However, this only gives me the index of the last iteration of the for loop. but I want all iteration saved.

%demo array. Has a run starting at indices 6 (length = 40), 49 (length = 25) and 112 (length = 30)%also has a run of 24 at index 78ex_threshold_postDC1 = [zeros(1, 5), ones(1, 40), zeros(1, 3), ones(1, 25), zeros(1, 4), ones(1, 24), zeros(1,10), ones(1, 30)]%find start indices of runs of length 25 or more:indices = find(diff(movsum(ex_threshold_postDC1, [0 24], 'Endpoints', 'discard') == 25) == 1) + 1