How to divide a signal into windows using loops
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mohamed Medhat
am 17 Jan. 2021
Bearbeitet: Adam Danz
am 18 Jan. 2021
i have a signal y which is 11439 long supposing it is y=randn(1,11439) which I want to divide into windows of lengths [16,64,256,1024,4096] where each window overlaps with 50% of the previous window
using 16 as an example I want the whole signal to be divided to windows of length 16 where each window overlaps with the previous by 50% like 1:16 then 8:24 and store each window
how can I implement that using a for loop or if statement
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 17 Jan. 2021
Bearbeitet: Adam Danz
am 18 Jan. 2021
y=randi(100,1,11439); % Integers used for easy comparison
n = 16; % must be even
windowStart = [1, n/2+1:n/2:numel(y)];
windowStop = n:n/2:numel(y);
nColumns = floor(numel(y)/(n/2))-1;
ym = nan(nColumns,n);
for i = 1:nColumns
ym(i,:) = y(windowStart(i):windowStop(i));
end
View results; you can see columns 9:16 of row n match columns 1:8 for row n+1.
ym(1:4,:)
Any trailing values of y that didn't fit into the last window are ignored.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!