Extracting multiple signal segments without a for loop
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Signal Generation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!