performance - Signal segmentation with overlaps -


i have signals. same length (n = 1024). have break each ns = 7 segments l = 256 points there 50% overlapping. s = randi(10,[4 n]); can thought 4 signals. thinking saving break points in vector (calculate them manually!) , using 2 loops save new 4 * ns = 28 signals in cell, won't solution. there quicker way reshape?

this 1 approach -

%// parameters n = 1024 l = 256 num_seg = 2*(n/l)-1  %// indices first signal each column representing 1 segment. %// thus, there must 7 columns, representing 7 segments in signal. signal1_idx = bsxfun(@plus,[1:l]',[0:num_seg-1]*l/2);  %//'  %// indices signals in 3d array each 3d slice %// representing 1 signal  allsignals_idx = bsxfun(@plus,signal1_idx,permute([0:size(s,1)-1]*n,[1 3 2]))  %// index input array create 3d array output  st = s'  %//' out = st(allsignals_idx) 

how interpret output, out:

  • each column in each slice of out 1 segment 1 signal.
  • the number of columns in each 3d slice number of segments in signal.
  • each 3d slice of out each signal.

sample run 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 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -