Vous êtes sur la page 1sur 12

DIGITAL SIGNAL PROCESSING

LAB

2ATEL1

OBJECT:

ENIT 2013_2014

We will use some digital filtering commands with matlab such filter ,
impz ..
To study some signals .
Question 1 :
The order of the filter is 7.
Question 2 :

The input signal x(n)= cos(2*f0*n)


f0=500Hz , n0 , n [7..121]
the matlab code :

f0=500;fe=6000;
n=0:1/fe:0.02;
xn=cos(2*pi*f0.*n);
figure(1),plot(n,xn),legend('the input signal')

Representation of the input signal

Question 3 :

The matlab code :


y(1)=0.692*xn(1);
y(2)=2.238*y(1)+0.692*xn(2)-1.762*xn(1);
y(3)=2.238*y(2)-3.921*y(1)+0.692*xn(3)1.762*xn(2)+3.545*xn(1);
y(4)=2.238*y(3)-3.921*y(2)+3.844*y(1)+0.692*xn(4)1.762*xn(3)+3.545*xn(2)-3.925*xn(1);
y(5)=2.238*y(4)-3.921*y(3)+3.844*y(2)-3.075*y(1)+0.692*xn(5)1.762*xn(4)+3.545*xn(3)-3.925*xn(2)+3.545*xn(1);
y(6)=2.238*y(5)-3.921*y(4)+3.844*y(3)3.075*y(2)+1.367*y(1)+0.692*xn(6)-1.762*xn(5)+3.545*xn(4)3.925*xn(3)+3.545*xn(2)-1.762*xn(1);
for i=7:121
y(i)=2.238*y(i-1)-3.921*y(i-2)+3.844*y(i-3)-3.075*y(i4)+1.367*y(i-5)-0.478*y(i-6)+0.692*xn(i)-1.762*xn(i1)+3.545*xn(i-2)-3.925*xn(i-3)+3.545*xn(i-4)-1.762*xn(i5)+0.692*xn(i-6);
end
figure(2),plot(n,xn),hold
on,plot(n,y,'r'),xlabel('frequency')
The Representation :

The signal in blue represent the input signal X(n) then


3

In red represent the output signal by using directly


implementing the difference equation .
Question 4:
We will use filter matlab function :

xn=cos(2*pi*f0.*n);
b=[ 0.692, -1.762, 3.545, -3.925, 3.545, -1.762,
0.692];
a=[1, -2.238, 3.921, -3.844, 3.075, -1.367, 0.478];
y1=filter(b,a,xn);
figure(3), plot(n,y1)

The Representation :

When compared the two signal obtained on question (3) (in red)
and on question (4) ; we conclude that both methods resulted in
the same shape of the signal.
Question 5 :
the impulse response of the filter by using matlab s impz function .
The matlab code :
h=impz(b,a,120);
figure(22), plot(h), legend('the impulse response of
filter');
the representation :

IT WAS A BANDPASS FILTER


WE CAN REACH THE SAME CONCLUSION BY OBSERVING THE

CCLDE.

Question 8 :
The matlab code :
h=impz(b,a,120);
h1=impz(b,a,50);
h2=impz(b,a,32);
figure(33),
subplot(3,1,1);plot(h),legend('with 120 points');
subplot(3,1,2);plot(h1),legend('with 50 points');
subplot(3,1,3);plot(h2),legend('with 32 points');

if we truncate the impulse response down to 50 and 32 points , the signal


is delayed .

QUESTION 9:
THE MATLAB CODE

s=conv(h1,xn);
s1=conv(h2,xn);
figure(4),plot(s),hold on,plot(s1,'r')
,legend('output of filter 1','output of filter2');

THE REPRESENTATION :

the output obtained in this question wich we use the matlab function
conv is similair to the outputs obtained in q4 and q3.
There are the same type of signal ; periodic signal, same amplitude

QUESTION 10:
THE MATLAB CODE :
n=[1:120];
T=1/fe;
fe=6000;
x=cos(2*pi*500*T*n)+cos(2*pi*1200*T*n);
y2=filter(b,a,x);
figure(6),plot (y2,'r'),hold
on,plot(y1),legend('filtred signal','original
signal');

THE REPRESENTATION

It was a periodic signal with the same characteristics of the signal with a
single sinusoid.

QUESTION 11:
THE MATLAB CODE

[H,f]=freqz(b,a,120,fe);
[H1,f]=freqz(b,a,50,fe);
[H2,f]=freqz(b,a,32,fe);
figure(7),subplot(3,1,1);stem(H);
subplot(3,1,2);stem(H1);
subplot(3,1,3);stem(H2);
THE REPRESENTATION :

IT WAS ACOUPE BAND FILTER.

QUESTION 13:
THE MATLAB CODE :

path='C:\Users\user\Desktop\'
nom='Ann_Simone.wav';
fe=6000;
[G,fe]=wavread([path nom]);
sound(G);
Gs=filter(b,a,G);
sound(Gs);
the representation :

filtering eliminated the high frequencies


and the stress on the above letter "s"

10

11

12

Vous aimerez peut-être aussi