Digital Signal Processing

Lab 5

Exercise 1

Sampling and reconstruction of a sinusoidal signal

(a) (Page 147, Example 4.1)

 

T = 1/6000;

t = 0:1e-6:30*T;

xc = cos(4000*pi*t);

%xc = cos(16000*pi*t);

% sampling

n = 0:30;

x = cos(4000*pi*T*n);

%x = cos(16000*pi*T*n);

% processing

y = x;

% resonstruction

yc = zeros(size(t));

for i = 1:size(y,2),

    yc = yc + y(i)*sinc((t-(i-1)*T)/T);

end

figure(1)

plot(t,xc,'-',T*n, x, 'x')

figure(2)

plot(t,sinc(t/T))

figure(3)

plot(t,yc)

 

(b) (Page 148, Example 4.2)

Comment xc = cos(4000*pi*t);

and then uncomment %xc = cos(16000*pi*t);

 

 

Exercise 2

Discrete-time implementation of an ideal continuous-time bandlimited differentiator

(Page 158, Example 4.5)

 

T = 1/6000;

t = 0:1e-6:30*T;

xc = cos(4000*pi*t);

%xc = cos(16000*pi*t);

% sampling

n = 0:30;

x = cos(4000*pi*T*n);

%x = cos(16000*pi*T*n);

% processing

n1 = -30:-1;  n2 = 1:30;

h = [cos(pi*n1)./(n1*T), 0, cos(pi*n2)./(n2*T)];

y1 = conv(x,h);

y = y1(31:61);

% resonstruction

yc = zeros(size(t));

for i = 1:size(y,2),

    yc = yc + y(i)*sinc((t-(i-1)*T)/T);

end

figure(1)

plot(t,xc,'-',T*n, x, 'x')

figure(2)

plot(h)

figure(3)

plot(t,yc)

 

Exercise 3

Plots of log magnitude, phase, and group delay.

(Page 265, Example 5.8)

 

r = 0.9;  theta = pi/4;

w=0:pi/5000:2*pi;

H = 1./(1-2*r*cos(theta)*exp(-j*w)+r*r*exp(-j*w*2));

%   

mag=20*log10(abs(H));

phase=angle(H);

dw = pi/5000;

samples = -diff(phase)/dw;

 

figure(1)

plot(w,mag)

axis([0 2*pi -10 20])

figure(2)

plot(w,phase)

axis([0 2*pi -pi pi])

figure(3)

w2 = w(1,1:size(w,2)-1);

plot(w2,samples)

axis([0 2*pi -2 10])

 

 

Sources:

Fundamentals of Digital Signal Processing, by Joyce Van de Vegte, Prentice Hall, 2002.