Professional Documents
Culture Documents
American International University-Bangladesh (AIUB) Faculty of Engineering (EEE)
American International University-Bangladesh (AIUB) Faculty of Engineering (EEE)
Problem 1:
a) Now we will study how a filter affects sinusoidal inputs, and begin to understand the performance of the filter
as a function of the input frequency. Consider the following input signal,
x(n)=Acos(ωxn+φ); for n=0, 1, 2, . . . , L–1
If the discrete-time sinusoid is produced by sampling a continuous-time cosine, the discrete time frequency is
ωx=2π(F/fs). Generate L= 50 samples of a discrete-time cosine wave with A=7, φ=π/3 and ωx=0.125π. Store this
signal in the vector x.
Now use filter( ) to implement the following filters on the signal x. [Check your ID to be sure which filter is to
be used. Students with odd serials will use (1) equation and even serials will use (2)]
This is called a first-difference filter, but with a gain of five. In Matlab you must define the vector ‘B’ needed in
filter( ).
Plot the first 50 samples of both waveforms x(n) and y(n) on the same figure, using subplot. Use the
stem function to make a discrete-time signal plot.
Verify the amplitude and phase of x(n) directly from its plot in the time domain.
From the plot, observe that with the exception of the first sample y(0), the sequence y(n) seems to be a
scaled and shifted cosine wave of the same frequency as the input.
Determine the amplitude and phase of y(n) directly from the plot. Ignore the first output point, y(0).
Identify the difference between output and input phases.
b) Linearity Check:
Now multiply the vector x from part (a) by two to get x =2*x. Generate the signal y by filtering x with
a a a
Now form another input signal x that is the sum of x and x . Run x through the filter to get y and then
c a b c c
Page - 2
DSP Lab
Even
a)
Code Output
n=0:49;
xx=7*cos((0.125*pi*n)+pi/3);
subplot(211)
stem(n,xx)
bb=[5 5];
ww=-pi:pi/100:pi;
H=freqz(bb,1,ww);
y=filter(bb,1,xx);
subplot(212)
stem(n,y)
b)
Code Output
clc;
clear all;
xa=2*xx;
ya=filter(bb,1,xa);
subplot(211)
stem(n,xa)
subplot(212)
stem(n,ya(1:50))
Problem 2
Code Output
Page - 3
DSP Lab
xb=8*cos(pi*0.25.*n);
yb=filter(bb,1,xb);
subplot(211)
stem(n,xb)
subplot(212)
stem(n,yb(1:50))
Problem 3
Code Output
xc=xa+xb;
yc=filter(bb,1,xc);
figure(1)
subplot(211)
stem(n,xc)
subplot(212)
stem(n,yc(1:50))
yc=ya+yb;
figure(2)
subplot(211)
stem(n,xc)
subplot(212)
stem(n,yc(1:50))
Page - 4