具有重叠的信号分割

Signal segmentation with overlaps

我有一些信号。它们的长度都相同 (N = 1024)。我必须用 L = 256 点将每个分成 Ns = 7 段,这样会有 50% 的重叠。 S = randi(10,[4 N]); 可以认为是 4 个信号。我正在考虑将断点保存在一个向量中(手动计算它们!)并使用两个循环将新的 4 * Ns = 28 信号保存在一个单元格中,但这不是一个好的解决方案。那么有没有像reshape这样更快的方法呢?

这可能是一种方法 -

%// 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)

如何解释输出,out

  • out 的每个切片中的每一列都是来自一个信号的一个片段。
  • 每个 3D 切片中的列数就是信号中的段数。
  • out 的每个 3D 切片对应每个信号。

样本 运行 N = 16 & 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