L’UNIVERSITÉ IBN TOFAIL
FACULTÉ DES SCIENCES
DÉPARTEMENT DE PHYSIQUE
Rapport du TP 1-2 du Traitement de Signal
Élaboré par : Responsable du TP
Hassan ABOULFADAM Pr : Y. EL MERABET
Année Universitaire 2017/2018
RAPPORT DU TP 1 Hassan Aboulfadam
Corrigé du TP 1
1)- Dans un fichier nomme distance.m, créer la fonction qui permet de retourner la distance absolue et la distance
en x et y entre deux points de coordonnées (x1,y1) et (x2,y2).
f unction[d, dx, dy] = distance(x1 , y1 , x2 , y2 )
%DISTANCE Summary of this function goes here
% Detailed explanation goes here
dx = x2 − x1 ;
dy = y2 − y1 ;
d = sqrt(dx2 + dy2 ) ;
end
2)-Soit la fonction x (t) = sin (2*pi*50*t) +sin (2*pi*120*t) définie sur [0,0.6]. On définit le vecteur des temps
de la manière suivante : t = 0 :0.001 :0.6 ; représenter x en fonction de t en apportant tout le soin nécessaire à la
présentation du graphique (Axes, titre, etc.. . . ).
F IGURE 1 – x(t) en fonction du temps
2
RAPPORT DU TP 1 Hassan Aboulfadam
3) - Réaliser l’impulsion de Dirac :
n=[-10 :10] ;
f=[zeros(1,10) 1 zeros(1,10)] ;
stem(n,f)
axis([-10 10 -0.5 1.5 ]) ;
xlabel(’n’) ;
ylabel(’f’) ;
title(’f en fonction de n’) ;
-Réaliser un échelon unité :
n=[-10 :10] ;
f=[zeros(1,10) ones(1,11)] ;
stem(n,f)
axis([-10 10 -0.5 1.5 ]) ;
xlabel(’n’) ;
ylabel(’f’) ;
title(’f en fonction de n’) ;
-Réaliser un Porte :
n=[-10 :10] ;
f=[zeros(1,7) ones(1,7) zeros(1,7)] ;
stem(n,f)
xlabel(’n’) ;
ylabel(’f’) ;
title(’f en fonction de n’) ;
3
RAPPORT DU TP 1 Hassan Aboulfadam
-Réaliser un signal rampe :
t=[0 :10] ;
a=1 ;
r=a*t ;
stem(t,r)
xlabel(’t’) ;
ylabel(’r’) ;
title(’r en fonction de t’) ;
-Réaliser un signal sinus amorti :
t=[0 :0.1 :5] ;
y=exp(-t).*sin(2*pi*t) ;
stem(t,y)
xlabel(’t’) ;
ylabel(’y’) ;
title(’y en fonction de t’) ;
-Convolution de deux Porte Rect :
p=4 ;
N=21 ;
t=-2*N :1 :2*N
f=[zeros(1,N-p)ones(1,2*p+1)zeros(1,N-p)] ;
r=[zeros(1,N-p)ones(1,2*p+1)zeros(1,N-p)] ;
y=conv(f,r) ;
stem(t,y)
xlabel(’t’) ;
ylabel(’y’) ;
title(’y en fonction de t’) ;
4
RAPPORT DU TP 1 Hassan Aboulfadam
TP 2 : Série de Fourier
1) Écrire un programme qui génère les N premier harmonique .
N=2000 ;
t=[0 :0.01 :1] ;
f0=1 ;
f=0 ;
for k=0 :N
b=2/pi/(2*k+1)
f=f+b*sin(2*pi*(2*k+1)*f0*t)
end
plot(t,f)
xlabel(’t’) ;
ylabel(’f’) ;
5
RAPPORT DU TP 1 Hassan Aboulfadam
Décomposition en série de Fourier Complexe
a) - La décomposition en série de Fourier Complexe d’un signal périodique est : x(t) = ∑+∞
n=−∞ Cn e
in2π f t
2 π
Pour notre signal On trouve Cn = j(2×kπ) et αn = 2
b) - Programme qui permet de tracer la somme de 11 premier harmonique
N=11 ;
t=0 :0.01 :1 ;
f0=1/2 ;
x=0 ;
cn=(1/(1i*(2*k+1)*pi)) ;
for k=-N :N
x=x+cn.*exp(1i*(2*k+1)*2*pi*f0*t) ;
end
plot(t,x)
xlabel(’t’)
ylabel(’x’)
title(’x en fonction de t’)
c) Programme qui permet de tracer le spectre uni-latéral et bilatéral .
6
RAPPORT DU TP 1 Hassan Aboulfadam
N=5
subplot(121)
hold on
for k=-N :N
cn=1/(1i*(2*k+1)*pi) ;
stem((2*k+1)*pi,abs(cn)) ;
end
xlabel(’(2*k+1)*pi’)
ylabel(’spectre amplitude’)
subplot(122)
hold on
for k=-N :N
cn=1/(1i*(2*k+1)*pi) ;
stem((2*k+1)*pi,angle(cn),’r’) ;
end
xlabel(’(2*k+1)*pi’)
ylabel(’spectre de phase’)
a=0.25 ;
te=0.25 ;
fe=1/te ;
t=0 :0.01 :10 ;
subplot(211)
x=exp(-a*t).*sin(2*pi*fe*t) ;
plot(t,x) ;
xlabel(’t’)
ylabel(’x’)
f=linspace(-19,19,length(t)) ;
z=(2*pi*fp) ;
r = ((a + 1i ∗ pi ∗ f ).2 + (2 ∗ pi ∗ f p)2 ) ;
y=z./r ;
subplot(212)
plot(f,abs(y)) ;
xlabel(’f’)
ylabel(’y’)
7
RAPPORT DU TP 1 Hassan Aboulfadam
Programme qui permet de tracer le spectre du signale Cosinus d’aptitude A=4 et de fréquence F=1KHZ
a=4 ;
t=-1 :0.01 :1 ;
f0=1 ;
x=4*cos(2*pi*1*t) ;
subplot(211) ;
plot(t,x,’r’) ;
xlabel(’t’)
ylabel(’x’)
f=linspace(-1,1,length(t)) ;
X=2*((f+f0)==0) ;
Y=2*((f-f0)==0) ;
R=X+Y ;
subplot(212) ;
plot(f,R) ;
axis([-2,2,0,3])
xlabel(’f’)
ylabel(’R’)
Programme qui permet de tracer le spectre du signale Cosinus d’aptitude A=2 et de fréquence F=2KHZ
a=2 ;
t=-1 :0.01 :1 ;
f0=2 ;
x=2*cos(2*pi*1*t) ;
subplot(211) ;
plot(t,x,’r’) ;
xlabel(’t’)
ylabel(’x’)
f=linspace(-2,2,length(t)) ;
X=1*((f+f0)==0) ;
Y=1*((f-f0)==0) ;
R=X+Y ;
subplot(212) ;
plot(f,R) ;
axis([-4,4,0,3])
xlabel(’f’)
ylabel(’R’)
8
RAPPORT DU TP 1 Hassan Aboulfadam
1) le signal y(t) est un produit de deux signaux : le premier c’est le signal échelon unité x1 (t) = U(t) et le
deuxième est le signal cosinus x1 (t) = Cos(2π f0t) ce qui donne y(t) = x1 (t) × x2 (t)
2)Programme sous matlab qui trace les trois signaux :
t =-1 :0.01 :1 ;
f0=4 ;
subplot(311) ;
x1=t¿=0 ;
plot(t,x1) ;
title(’signal echelon’)
subplot(312) ;
x2=cos(2*pi*f0*t) ;
plot(t,x2,’y’) ;
title(’signal x2’)
subplot(313) ;
y=x1.*x2 ;
plot(t,y,’r’) ;
title(’signal y(t)’)
d) le spectre d’amplitude des deux signaux
9
RAPPORT DU TP 1 Hassan Aboulfadam
t =-1 :0.01 :1 ;
f0=4 ;
subplot(411) ;
x1=t¿=0 ;
plot(t,x1) ;
title(’signal echelon’)
%le spectre amplitude U
subplot(412)
f=linspace(-10,10,length(t))
A=1./(1i*2*pi*f) ;
B=0.5*f==0 ;
Y=A+B ;
stem(f,Y)
axis([-2,2,0,2]) ;
title(’le spectre de U’)
% le fignal x2
subplot(413) ;
x2=cos(2*pi*f0*t) ;
plot(t,x2,’y’) ;
title(’signal x2’)
% le spectre de fréquece
subplot(414) ;
f=linspace(-10,10,length(t))
Q=0.5*(f+f0)==0 ;
E=0.5*(f-f0)==0 ;
X=Q+E ;
stem(f,abs(X)) ;
title(’spectre x2’)
10