フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

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

1 回表示 (過去 30 日間)
yonatan friedman
yonatan friedman 2019 年 12 月 10 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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