TP4 - Systèmes invariants par translation¶
On considère un système linéaire invariant par translation dont la matrice a pour première colonne $h_0$. Ce vecteur est donné par la fonction
$$ g_{m,\sigma}(t) = e^{-(t-m)^2/(2\sigma^2)} $$
échantillonné sur la grille t_grid
associée à $f_a$.
1) A partir de t_grid
créer le vecteur $h_0$ et la matrice $A$ associée au système linéaire pour $m=0$ et $\sigma=0.1\, dt$. On pourra illustrer graphiquement $h_0$ pour voir à quoi il ressemble.¶
In [215]:
g = lambda t, m, sig: np.exp(-0.5*(t-m)**2/sig**2)
In [216]:
h0 = g(t_grid, 0, 0.1 * dt)
In [217]:
plt.plot(t_grid, h0, 'o-')
Out[217]:
[<matplotlib.lines.Line2D at 0x797b04bde200>]
In [218]:
def circulant_matrix(vector):
n = len(vector)
matrix = np.zeros((n, n), dtype=vector.dtype)
for i in range(n):
matrix[i] = np.roll(vector, i)
return matrix
A = circulant_matrix(h0)
2) On applique ce système à $f_a$ échantillonnée sur la grille t_grid
, c'est à dire à $f(t_n)$. Illustrer graphiquement la sortie de ce système, c'est à dire la convolution discrète de $h_0$ par $f(t_n)$, et la comparer avec $f(t_n)$.¶
In [219]:
conv_discrete = np.matmul(A, f_discrete)
In [220]:
plt.plot(t_grid, np.real(f_discrete), 'o-')
plt.plot(t_grid, np.real(conv_discrete), 'o-')
Out[220]:
[<matplotlib.lines.Line2D at 0x797b04a4e260>]
In [221]:
plt.plot(t_grid, np.imag(f_discrete), 'o-')
plt.plot(t_grid, np.imag(conv_discrete), 'o-')
Out[221]:
[<matplotlib.lines.Line2D at 0x797b04ab2b30>]
3) Jouer avec les paramètre $m$ et $\sigma$ pour voir comment ce système affecte le signal d'entré.¶
In [240]:
m, sig = 1., 2*dt
In [241]:
h0 = g(t_grid, m, sig)
A = circulant_matrix(h0)
In [242]:
plt.plot(t_grid, h0, 'o-')
Out[242]:
[<matplotlib.lines.Line2D at 0x797b046e2800>]
In [243]:
conv_discrete = np.matmul(A, f_discrete)
In [244]:
plt.plot(t_grid, np.real(f_discrete), 'o-')
plt.plot(t_grid, np.real(conv_discrete), 'o-')
Out[244]:
[<matplotlib.lines.Line2D at 0x797b0454a9b0>]
In [245]:
plt.plot(t_grid, np.imag(f_discrete), 'o-')
plt.plot(t_grid, np.imag(conv_discrete), 'o-')
Out[245]:
[<matplotlib.lines.Line2D at 0x797b045bef80>]