For-Loop Midpoint Help
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!