Manipulations simples pour le traitement du signal

par Joseph Razik, le 2019-10-18
1-Manipulations_simples_py3

Exemples de manipulations simples sur des signaux élémentaires

L'objectif principal est de se familiariser avec des signaux élémentaires (discret) ainsi que savoir les manipuler. Le second objectif est de se familiariser aussi avec le langage python pour ces manipulations.

Définissez et affichez la fonction de kronecker (delta) définie par $\delta(n) = 1$ si $n = 0$; et $0$ sinon. Appelez votre fonction "delta", et affichez là sur l'intervalle [-20,20].

In [1]:
%pylab inline
Populating the interactive namespace from numpy and matplotlib
In [2]:
def delta(n):
    return 1 if n == 0 else 0
In [3]:
stem(range(-20,21), [delta(n) for n in range(-20,21)])
ylim(-0.1, 1.1)
xlim(-20,20)
Out[3]:
(-20, 20)

Définissez et affichez la fonction unité définie par $unit(n) = 1$ si $x \ge 0$, $0$ sinon. Appelez votre fonction "unit".

In [4]:
def unit(n):
    return 1 if n >= 0 else 0
In [5]:
stem(range(-20,21), [unit(n) for n in range(-20,21)])
ylim(-0.1, 1.1)
xlim(-20,20)
Out[5]:
(-20, 20)

Affichez les fonctions $\delta(-n)$, $\delta(n-5)$, $\delta(n+5)$. Que remarquez vous ?

In [6]:
# delta(-n)
stem(range(-20,21), [delta(-n) for n in range(-20,21)])
ylim(-0.1, 1.1)
xlim(-20,20)

# delta(n-5)
figure()
stem(range(-20,21), [delta(n-5) for n in range(-20,21)])
ylim(-0.1, 1.1)
xlim(-20,20)

# delta(n+5)
figure()
stem(range(-20,21), [delta(n+5) for n in range(-20,21)])
ylim(-0.1, 1.1)
xlim(-20,20)
Out[6]:
(-20, 20)

Même chose avec la fonction unité. Que remarquez-vous ?

In [7]:
# unit(-n)
stem(range(-20,21), [unit(-n) for n in range(-20,21)])
ylim(-0.1, 1.1)
xlim(-20,20)

# unit(n-5)
figure()
stem(range(-20,21), [unit(n-5) for n in range(-20,21)])
ylim(-0.1, 1.1)
xlim(-20,20)

# unit(n+5)
figure()
stem(range(-20,21), [unit(n+5) for n in range(-20,21)])
ylim(-0.1, 1.1)
xlim(-20,20)
Out[7]:
(-20, 20)

Affichez la fonction de $|\alpha|^n.unit(n)$ pour les valeurs $\alpha$ 0.95, 0.9 et 0.6. Que remarquez-vous ?

In [8]:
# alpha = 0.95
stem(range(-20,21), [(0.95**n)*unit(n) for n in range(-20,21)])
ylim(-0.1, 1.1)
xlim(-20,20)

# alpha = 0.9
figure()
stem(range(-20,21), [(0.9**n)*unit(n) for n in range(-20,21)])
ylim(-0.1, 1.1)
xlim(-20,20)

# alpha = 0.5
figure()
stem(range(-20,21), [(0.6**n)*unit(n) for n in range(-20,21)])
ylim(-0.1, 1.1)
xlim(-20,20)
Out[8]:
(-20, 20)

Travail sur les nombres complexes

Soit le nombre complexe $z=4+3i$ (en python, la notation $j$ est utilisée). Affichez dans le plan complexe $z$, $z\times e^{i\pi/2}$, $z\times (-i)$, $\bar{z}$, $z+\bar{z}$ et $z-\bar{z}$

In [9]:
def affiche_complexe(z):
    plot(z.real, z.imag, 'o', label=str(z))
In [10]:
z = 4 + 3j
figure(figsize=(10,10))
affiche_complexe(z)
affiche_complexe(z * exp(1j * pi / 2.0))
affiche_complexe(z * (-1j))
affiche_complexe(z.conjugate())
affiche_complexe(z + z.conjugate())
affiche_complexe(z - z.conjugate())
axhline(0, color='k')
axvline(0, color='k')
xlim(-10,10)
ylim(-10,10)
legend()
axvline(4, color='g')
plot([-6,6], [8,-8])
plot([-2*z.real, 2*z.real], [-2*z.imag, 2*z.imag], 'b')
Out[10]:
[<matplotlib.lines.Line2D at 0x7f86816d6080>]