Parsing an array A based on trigger data in array B ?
Mostrar comentarios más antiguos
Hi everyone!
I have what should be a simply question but I cannot seem to find an effective solution. I have two columns of data in Excel files that I read into Matlab, at the moment as two separate arrays (column A and B).
Column A contains numeric data and Column B is a trigger stamp for the data in A. Example:

What I need to do is to parse A and split it into a number of (30) arrays depending on the trigger point in B i.e. the very large A would become A1, A2, A3 ... A30, split according to when there is a data-stamp in B.
2 comentarios
Jan
el 3 de Jul. de 2013
Please post how you "read the Excel file". Then creating a matching answer is easier.
Respuesta aceptada
Más respuestas (1)
I'm sure there are more elegant solutions, but here's one way:
idx1 = find(~isnan(B));
idx2 = [idx1(2:end)-1; length(A)];
C = cell(length(idx1), 1);
for k = 1:length(idx1)
C{k} = A(idx1(k):idx2(k));
end
If the non trigger values in B are zeros then:
idx1 = find(B>0);
-Rob
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!