How to use for loop for below

1 回表示 (過去 30 日間)
Amit Pandey
Amit Pandey 2017 年 12 月 7 日
コメント済み: Amit Pandey 2017 年 12 月 7 日
i have 3 vectors. 1st is time(12000,1). 2nd is A(12000,1), which is either 0 or 1 throughout time randomly. third is B(12000,1), which again is randomly 0and 1 in time. i want to find all points where B==1 within 5 Secs of A==0. (Total number of ones in A and B are different)

採用された回答

Andrei Bobrov
Andrei Bobrov 2017 年 12 月 7 日
Here tAB - your array (first column - time in seconds)
ii = tAB(tAB(:,2) == 0,1);
lo = false(size(tAB,1),1);
for jj = 1:numel(ii)
lo = lo | tAB(:,1) >= ii(jj) - 3 & tAB(:,1) <= ii(jj) + 3 & tAB(:,3);
end
out = tAB(lo,1);
  1 件のコメント
Amit Pandey
Amit Pandey 2017 年 12 月 7 日
thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by