I have problem with upsampling implementation in the following way:
My code:
def expand(x, L, t=None):
"""
This function expands a given signal L-times. It also returns new timestamps if they were given.
Parameters:
x - Vector to expand.
L - Expansion factor. It should be an integer.
Returns:
y_L - Expanded signal.
t_L - New timestamps.
"""
n = L * len(x)
y_L = np.empty(n)
t_L = np.zeros(n)
#delta_t = np.abs(t[0]-t[1])
#delta_t_L = delta_t/L
for i in range(n):
if i % L == 0:
y_L[i] = x[i//L]
else:
y_L[i] = 0
t_L = np.arange(n)/L
#t_L = np.arange(0,len(x),delta_t_L).tolist() (Working only for [1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1])
if t is None:
return y_L
return y_L, t_L
The problem is with 't_L' array. I don't know how to define it correct.
It's working for this signal '[1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1]' but then I tried to decimate this signal and then extend it in this way
K = 5
L = 3
y_K, t_K = decimate(x, K, t)
y_L, t_L = expand(y_K, L, t_K)
For [1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1], L = 2:
For [1. 6. 3.], K = 5 (Decimation factor):
Could you help me find the solution for this problem?