For-Loop Midpoint Help
Mostra commenti meno recenti
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
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!