Escolar Documentos
Profissional Documentos
Cultura Documentos
Hyderabad Campus
Digital Signal Processing
Lab 2
(You are instructed to write solutions, plots, observations and explorations in your
observation record and get it signed before leaving the lab)
[A] A sinusoidal signal s(t) is of frequency 1 Hz and peak amplitude of 1.
1. (i) Assume s(t) is sampled with sampling frequency of 10 Hz. Sub plot the
samples of sinusoid for 4 sec .
f=1;
fs=10;
T=4;
dt=1/fs;
x=sin(2*pi*[0:dt:T])
subplot(1,2,1)
stem([0:dt:T],x)
(ii) Now plot the continuous signals connecting these samples as the second sub
plot.
f=1;
fs=10;
T=4;
dt=1/fs;
x=sin(2*pi*[0:dt:T])
subplot(1,2,1)
stem([0:dt:T],x)
subplot(1,2,2)
plot([0:dt:T],x)
2. (i) Assume s(t) is sampled with sampling frequency of 2 Hz. Plot the samples of
sinusoid for 4 sec.
f=1;
fs=2;
T=4;
dt=1/fs;
x=sin(2*pi*[0:dt:T])
subplot(1,2,1)
stem([0:dt:T],x)
(ii) Now plot the continuous signals connecting these samples as the second sub
plot.
f=1;
fs=2;
T=4;
dt=1/fs;
x=sin(2*pi*[0:dt:T])
subplot(1,2,1)
stem([0:dt:T],x)
subplot(1,2,2)
plot([0:dt:T],x)
subplot(2,1,1)
y=5*x;
plot(y)
sound(y)
subplot(2,1,2)
z=x/5;
plot(z)
sound(z)
3. Add some DC value of 100 and then display the image in gray scale as second
plot in subplot of three.
4. Subtract some DC value of 100 from original image and then display the image in
gray scale as third plot in subplot of three.
subplot(2,2,2);
plot(n,s2);
axis([0, 100, -2, 2]);
xlabel('Time index n'); ylabel('Amplitude');
title('Signal # 2');
subplot(2,2,3);
plot(n,x);
axis([0, 100, -2, 2]);
xlabel('Time index n'); ylabel('Amplitude');
title('Input Signal');
subplot(2,2,4);
plot(n,y);
axis([0, 100, -2, 2]);
xlabel('Time index n'); ylabel('Amplitude');
title('Output Signal');
axis;
b =
0.2000
0.2000
0.2000
0.2000
0.2000
a = 1;
Find the moving-average of the data with a window size of 5.
y = filter(b,a,x);
y(1) is equivalent to 0.2*x(1).
y(2) is equivalent to 0.2*(x(1)+x(2)).
...
y(5) is equivalent to 0.2*(sum(x(1:5)) = mean(x(1:5)).
y(6) is equivalent to mean(x(2:6)).
...
y(100) is equivalent to mean(x(96:100)).
1. Now change the program so that it will find y3, y10, y50 and y100 corresponding
to M = 3, 10, 50 and 100. Plot the inputs s1, x and four outputs corresponding to
different values of M.
M=3
M=10
M=50
M=100
2. Explain the function of the above program and comments/remarks based on
different outputs obtained for M = 3, 10, 50 and 100.