How to use for loop for below
1 回表示 (過去 30 日間)
古いコメントを表示
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)
0 件のコメント
採用された回答
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);
その他の回答 (0 件)
参考
カテゴリ
Help Center および 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!