Professional Documents
Culture Documents
Lab 5b
Lab 5b
Lab 5b
Day: Monday
Object: Sampling of sinosidal signal taking 4 inputs from users with following conditions.
Fmax = 13; Fs1 = 2*Fmax = 26; Fs2 > 2*Fmax = 28; Fs3 < 2*Fmax =20.
Source code:
clc
t = 0:0.0005:1;
f = input ('Enter Max Frequency');
xa = cos(2*pi*f*t);
subplot (2,2,1);
plot (t,xa);
grid;
xlabel ('Time Sec');
ylabel ('Amplitude');
title ('Continuous Time Signal');
axis ([0 1 -1.2 1.2])
fs1 = input ('Enter fs1 = 2f max');
T = 1/fs1;
n = 0:T:1;
xs = cos(2*pi*f*n);
k = 0: length(n)-1;
subplot (2,2,2);
stem (k,xs,'filled','--');
grid;
xlabel ('Time Sec');
ylabel ('Amplitude');
title ('Discrete Time Signal');
axis ([ 1 30 -1.2 1.2])
fs2 = input ('Enter fs2 > 2f max');
T2 = 1/fs2;
n1 = 0:T2:1;
xs = cos(2*pi*f*n1);
l = 0: length(n1)-1;
subplot (2,2,3);
stem (l,xs,'filled','--');
grid;
xlabel ('Time Sec');
ylabel ('Amplitude');
title ('Discrete Time Signal');
axis ([ 1 30 -1.2 1.2])
fs3 = input ('Enter fs3 < 2f max');
T3 = 1/fs3;
n2 = 0:T3:1;
xs = cos(2*pi*f*n2);
m = 0: length(n2)-1;
subplot (2,2,4);
stem (m,xs,'filled','--');
grid;
xlabel ('Time Sec');
ylabel ('Amplitude');
Output:
Discrete Time Signal
0.5
0.5
Amplitude
Amplitude
-0.5
-0.5
-1
-1
0
0.2
0.4
0.6
Time Sec
0.8
0.5
0.5
-0.5
-1
-1
10
15
Time Sec
20
20
25
30
25
30
-0.5
15
Time Sec
Amplitude
Amplitude
10
25
30
10
15
Time Sec
20