필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Given a logical vector v, and a positive integer n, return the smallest index i that satisfies

조회 수: 1 (최근 30일)
Given a logical vector v, and a positive integer n, return the smallest index i that satisfies
all( v(i : i+n-1) ) == true
For Example,
input : v = logical([0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0]);
input : i = consecutiveFind(v, 4);
Then:
output : i = 6

답변 (1개)

yonatan friedman
yonatan friedman 2019년 12월 10일
i tried this:
for i = length(v)
while i + n -1 < length(v)
if all( v(i : i+n-1) ) == true
disp(sum(v(i:i+n-1)))
end
end
end
but i get 7 every time

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by