Indexing to return segments
Mostrar comentarios más antiguos
Hi. I know this could look like a silly question but can't find a way to do it. I have a matrix (data) that is 14258 x 7, the first six columns are data from a subject and the last column are time markers (0 off and 5 is on).
I used ischange on the last column to have the changing points:
[index,~] = ischange(data(:,7))
The problem is that I should end with 10 segments (of different duration) that include the data of the other 6 columns, but I don't know how to use the index to have it.
Thanks in advance
Respuesta aceptada
Más respuestas (1)
Bob Thompson
el 29 de En. de 2021
It looks like the index output is actually a logic array. I recommend using find to identify the actual indexes of the identified changes. I imagine it woud look something like the following, but it is untested:
[index] = find(ischange(data(:,7))==1);
I'm not quite sure how you want to utilize the different sections, but you could capture the different time elements in a cell array kind of like the following:
timedata{1} = data(1:index(1)-1,1:6);
for i = 1:length(index)-1
timedata{i+1} = data(index(i):index(i-1),1:6);
end
timedata{length(index)+1} = data(index(end):end,1:6);
1 comentario
Frank Pernett
el 9 de Mzo. de 2021
Categorías
Más información sobre Timing and presenting 2D and 3D stimuli en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!