How to divide a signal into windows using loops
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Adam Danz
2021-1-17
编辑:Adam Danz
2021-1-18
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!