Signal segmentation with overlapping

I have some signals. They are the same length ( N = 1024

). I have to split each into Ns = 7

segments with L = 256

dots so there will be 50% overlap. S = randi(10,[4 N]);

can be viewed as 4 signals. I was thinking about storing the breakpoints in the vector (calculating them manually!) And using two loops to store the new signals 4 * Ns = 28

in the cell, but that wouldn't be a good solution. So, is there a faster way how reshape

?

+3


source to share


1 answer


This could be one approach -

%// Parameters
N = 1024
L = 256
num_seg = 2*(N/L)-1

%// Indices for the first signal with each column representing one segment.
%// Thus, there must be 7 columns, representing those 7 segments in a signal.
signal1_idx = bsxfun(@plus,[1:L]',[0:num_seg-1]*L/2);  %//'

%// Indices for the all the signals in a 3D array with each 3D slice
%// representing one signal 
allsignals_idx = bsxfun(@plus,signal1_idx,permute([0:size(S,1)-1]*N,[1 3 2]))

%// Index into the input array to create a 3D array output 
St = S'  %//'
out = St(allsignals_idx)

      

How to interpret the output out

:



  • Each column in each chunk out

    will be one segment from one signal.
  • The number of columns in each 3D segment will be the number of segments in the signal.
  • Each 3D slice out

    will be for each signal.

Example run for N = 16

and L = 4

:

>> S
S =
     6    10     9     2     3     1     8     8     4     5     7    10     5     8    10     9
     8     9     5     4     4     4     7     2     9     4     3     7     4     7     4     9
     5     4     5    10     7    10     7     9     2     7     2     8     9     9     1     4
     7     3     2     1     1    10     3     1     8     3     4    10     4     4     4    10
>> out
out(:,:,1) =
     6     9     3     8     4     7     5
    10     2     1     8     5    10     8
     9     3     8     4     7     5    10
     2     1     8     5    10     8     9
out(:,:,2) =
     8     5     4     7     9     3     4
     9     4     4     2     4     7     7
     5     4     7     9     3     4     4
     4     4     2     4     7     7     9
out(:,:,3) =
     5     5     7     7     2     2     9
     4    10    10     9     7     8     9
     5     7     7     2     2     9     1
    10    10     9     7     8     9     4
out(:,:,4) =
     7     2     1     3     8     4     4
     3     1    10     1     3    10     4
     2     1     3     8     4     4     4
     1    10     1     3    10     4    10

      

+3


source







All Articles