How to signal divide into windows of lengths [1024] .

5 views (last 30 days)
I have a signal x which is 43939 , which I want to divide into windows of lengths [1024] where each window overlaps with 50% of the previous window.using 1024 as an example I want the whole signal to be divided to windows of length 1024 where each window overlaps with the previous by 50% like 1:1024 then 512:1536 and store each window how can I implement that using a for loop or if statement then how to I use discrete wavelet transform (DWT) for the signal decomposion to 10 levels

Answers (2)

Dave B
Dave B on 16 Nov 2021
How about assembling up a matrix marking the indices of x you want. Of course you'll have to do something so that it's divisible by 512 (like pad the end).
x=rand(1,43939);
% pad at the end?
x=padarray(x,[0 512-mod(numel(x),512)],nan,'post');
start=(1:512:numel(x)-512)';
ind=start+(0:1023);
% just a view of what this looks like:
ind(1:3,1:5)
ans = 3×5
1 2 3 4 5 513 514 515 516 517 1025 1026 1027 1028 1029
ind(1:3,end-5:end)
ans = 3×6
1019 1020 1021 1022 1023 1024 1531 1532 1533 1534 1535 1536 2043 2044 2045 2046 2047 2048
y = x(ind);
For the wavelet bit, it sounds like wavedec, but that's about all I know.

Star Strider
Star Strider on 16 Nov 2021
Use the buffer function. It will do everything desired.
signal = 1:100;
winlen = 10; % WindowLength
overlap = fix(winlen/2); % 50% Overlap
out = buffer(signal, winlen, overlap)
out = 10×20
0 1 6 11 16 21 26 31 36 41 46 51 56 61 66 71 76 81 86 91 0 2 7 12 17 22 27 32 37 42 47 52 57 62 67 72 77 82 87 92 0 3 8 13 18 23 28 33 38 43 48 53 58 63 68 73 78 83 88 93 0 4 9 14 19 24 29 34 39 44 49 54 59 64 69 74 79 84 89 94 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 1 6 11 16 21 26 31 36 41 46 51 56 61 66 71 76 81 86 91 96 2 7 12 17 22 27 32 37 42 47 52 57 62 67 72 77 82 87 92 97 3 8 13 18 23 28 33 38 43 48 53 58 63 68 73 78 83 88 93 98 4 9 14 19 24 29 34 39 44 49 54 59 64 69 74 79 84 89 94 99 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100
The wavelet decomposition then depends in part on the sort of wavelet that will give the best results for the intended decomposition. I have not used wavelets frequently enought to consider myself skilled in their use, so I do not feel comfortable commenting on that part.
.

Categories

Find more on Discrete Multiresolution Analysis in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!