Extracting multiple signal segments without a for loop
Mostrar comentarios más antiguos
If I have a vector signal, how may I extract certain segments if I have the indices of the beginning of these segments (and I want to take for example 100 points after each segment onset, and arrange them in a nSegments by 100 matrix?
This is easy to do in a for loop (see example below), but I would love to find a vectorized way to do it, without a loop, if it is even possible.
signal = rand(1000,1);
segmentOnsetIndices = [50 120 550 600 750];
for idx = 1:length(segmentOnsetIndices)
signalSegments(idx,:) = signal(segmentOnsetIndices(idx):segmentOnsetIndices(idx)+100)
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Signal Generation 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!