Professional Documents
Culture Documents
Laboratory Exercise#02: Objective TASK#1
Laboratory Exercise#02: Objective TASK#1
(2012-EE-111)
(2012-EE-224)
(2012-EE-)
LABORATORY EXERCISE#02
OBJECTIVE:
TASK#1:
Write a script to generate a continuous time sinusoid signal with amplitude=2 for a
time 0 to 1 sec and taken the frequency as a user input by using input command.
CODING:
f=input ('Enter Frequency f=');
a=2;
t=0:0.01:1;
b=a*sin(2*pi*f*t);
plot(t,b);
xlabel('Frequency');
ylabel('Amplitude');
title('Sine Wave');
RESULT:
Enter Frequency f=5
GRAPH:
Sine Wave
2
1.5
1
Amplitude
0.5
0
-0.5
-1
-1.5
-2
0.1
0.2
0.3
0.4
0.5
0.6
Frequency
0.7
0.8
0.9
Page 7
(2012-EE-111)
(2012-EE-224)
(2012-EE-)
TASK#2: Write a script to convert continuous time signal to a discrete time signal and take
the frequency as input which should be less than, equal to and greater than the twice the
maximum signal sampling frequency in Hertz use subplot command to plot it for 10s
CODING:
f=input('Enter Frequency=')
a=2;
t=0:0.01:1;
b=a*sin(2*pi*f*t);
Subplot(2,2,1);
plot(t,b);
xlabel('Frequency');
ylabel('Amplitude');
fs1=2*f*0.5;
fs2=2*f*1;
fs3=2*f*1.5;
n1=0:1/fs1:10;
n2=0:1/fs2:10;
n3=0:1/fs3:10;
c=sin(2*pi*(f/fs1)*n1);
Subplot(2,2,2);
Stem(n1,c);
xlabel('Frequency');
ylabel('Amplitude');
d=a*sin(2*pi*(f/fs2)*n2);
Subplot(2,2,3);
Stem(n2,d);
xlabel('Frequency');
ylabel('Amplitude');
e=a*sin(2*pi*(f/fs3)*n3);
Subplot(2,2,4);
Stem (n3,e);
xlabel('Frequency');
ylabel('Amplitude');
DIGITAL SIGNAL PROCESSING
Page 8
(2012-EE-111)
(2012-EE-224)
(2012-EE-)
RESULT:
Enter Frequency =2
fs1 =2
fs2 =4
fs3 =6
GRAPH:
-15
10
Amplitude
Amplitude
0
-1
0.5
Frequency
-5
Amplitude
Amplitude
-2
0
-1
-2
x 10
5
Frequency
10
5
Frequency
10
0
-1
5
Frequency
10
-2
TASK#3: Write a script to convert continuous time signal to a discrete time signal and take the
sampling frequency as input which should be less than, equal to and greater than the twice the
maximum signal frequency in Hertz use subplot command to plot it for 10s, also redefine the
function of sampling theorem and also derive it mathematically.
CODING:
fs=input('Enter Frequency fs=')
a=2
t=0:0.01:1;
b=a*sin(2*pi*f*t);
Subplot(2,2,1);
plot(t,b);
xlabel('Frequency');
ylabel('Amplitude');
DIGITAL SIGNAL PROCESSING
Page 9
(2012-EE-111)
(2012-EE-224)
(2012-EE-)
f1=2*(fs/2)*0.5
f2=2*(fs/2)*1
f3=2*(fs/2)*1.5
n1=0:1/fs: 10
n2=0:1/fs: 10
n3=0:1/fs: 10
c=a*sin (2*pi*(f1/fs)*n1)
Subplot (2, 2,2)
Stem (n1, c)
xlabel('frequency');
ylabel('amplitude');
d=a*sin (2*pi*(f2/fs)*n2)
Subplot (2, 2,3)
Stem (n2,d)
xlabel('frequency');
ylabel('amplitude');
e=a*sin (2*pi*(f3/fs)*n3)
Subplot (2, 2,4)
Stem (n3,e)
xlabel('frequency');
ylabel('amplitude');
RESULT:
Enter Frequency fs =2
f1 = 0.5
f2 = 2
f3 = 3
Page 10
(2012-EE-111)
(2012-EE-224)
(2012-EE-)
amplitude
Amplitude
GRAPH:
0
-1
-2
0
-1
0.5
Frequency
-2
5
frequency
10
5
frequency
10
-15
x 10
10
amplitude
amplitude
15
5
0
-5
1
0
-1
5
frequency
10
-2
RESULT:
Enter Frequency fs=5
f = 2.5
Page 11
(2012-EE-111)
(2012-EE-224)
(2012-EE-)
GRAPH:
Sinewave
2
1.5
1
Amplitude
0.5
0
-0.5
-1
-1.5
-2
5
Frequency
10
CODING:
(i)
(ii)
fs=200;
f=50;
n=0:1/fs:fs/f;
x=3*cos(2*pi*(f/fs)*n);
stem(n,x);
grid on;
xlabel('frequency');
DIGITAL SIGNAL PROCESSING
Page 12
(2012-EE-111)
(2012-EE-224)
(2012-EE-)
ylabel('amplitude');
title('fs=200');
(iii)
fs=75;
f=50;
n=0:1/fs:fs/f;
x=3*cos(2*pi*(f/fs)*n);
stem(n,x);
grid on;
xlabel('frequency');
ylabel('amplitude');
title('fs=75');
(iv)
f1=25;
f2=75;
t=0:0.01:1;
x1=3*cos(2*pi*f1*t);
x2=3*cos(2*pi*f2*t);
plot(t,x1);
plot(t,x2);
grid on;
xlabel('Frequency');
ylabel('Amplitude');
title('Aliasing fs=75');
GRAPH:
(ii):
fs=200
3
amplitude
-1
-2
-3
0.5
1.5
2
frequency
2.5
3.5
Page 13
(2012-EE-111)
(2012-EE-224)
(2012-EE-)
(iii)
fs=75
3
amplitude
-1
-2
-3
0.5
1.5
frequency
(iv):
Aliasing fs=75
3
Amplitude
-1
-2
-3
0.1
0.2
0.3
0.4
0.5
0.6
Frequency
0.7
0.8
0.9
CONCLUSION:
Page 14