There is a matrix Idx = [1xM]
with M dimension of index numbers of a signal to be extracted. For each index number, from left to right certain numbers of samples should be extracted to form a new sub-signal of original signal.
For example, 3 samples from left and 4 samples from right of an index number see below:
[idx-3:idx+4]
[New_Sig] becomes an one-row matrix instead of being the same dimension of index number from index matrix [Idx]
Fs = 500; %Frequency:500
StartIdx = 0.150 * Fs;
EndIdx = 0.500 * Fs;
[Idx] = [.....];
[New_Sig] = [Idx-StartIdx : Idx+EndIdx];
Here is an example for two index points from Idx
matrix below:
[Idx] = [2 19 23 43 48 52 62 74 78 79 81]
old_sig = [-2 0 1 2 5 6 7 8 10 19 20 21 22 23 24 25 ...]
if # of sample from left = 3, # of sample from right = 4:
a_new_sub = [-2 0 1 **2** 5 6 7 8]
b_new_sub = [7 8 10 **19** 20 21 22 23]
.....
Here's my suggestion to solve this issue:
As output, we get:
Caveat: At the moment, your
old_sig
contains unique values. Therefore, thefind
will find the correct (unique) index. If the values in your signal do repeat, one need to specify which value should be found.Another caveat: Depending, on how large your signal
old_sig
is, and how many indices you have inIdx
, this approach might get memory intensive.