Conditional Indexing of a cumsum
3 views (last 30 days)
From a random data k, I would like to fulfill 2 Conditions:
1) Cumsum until 3.5mm - Fulfilled
2) Each cumsum interval must be more than 4 index
Below is the code:
clean = k(,:);
indclean = ;
k = rand(1000,1);
for ii = startind % Iterate over start indices
cs = cumsum(k(ii:end));
inds3_5 = ii-1 + find(cs <= 1); % Find where data is below the 3.5mm threshold; adjust based on the start index.
clean = [clean;k(inds3_5,:)]; % append data
indclean = [indclean; inds3_5]; % append indices
Hence, how do I make it so that only cumsum that last more than 4 indexes are used.