How to use for loop for below

5 Ansichten (letzte 30 Tage)
Amit Pandey
Amit Pandey am 7 Dez. 2017
Kommentiert: Amit Pandey am 7 Dez. 2017
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)

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 7 Dez. 2017
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);

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by