How to use for loop for below
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Amit Pandey
el 7 de Dic. de 2017
Comentada: Amit Pandey
el 7 de Dic. de 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)
0 comentarios
Respuesta aceptada
Andrei Bobrov
el 7 de Dic. de 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);
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!