I'm looking to make a for-loop that looks 50 indices ahead and 50 indices behind, but the code won't precede past the line: elseif sum(count(max(i-49,1)):i,length(count)) > 1, I think it has something to do with the max function, but can't seem to work around it. Any help would be appreciated. Count is already defined as a vector of zeros or ones previously in the script.
for i = 1:length(count); if sum(count(i:min(i+49,length(count)))) > 1 count(i) = 50; elseif sum(count(max(i-49,1)):i,length(count)) > 1 count(i) = 50; else count(i) = 0; end end
Best Answer