Extracting multiple signal segments without a for loop
Mostra commenti meno recenti
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
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Signal Generation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!