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!