Professional Documents
Culture Documents
LAB FILE
EC 453
INDEX
TOPIC
SR.
1.
2.
4.
5.
6.
Linear Convolution
7.
Circular Convolution
8.
9.
DTFT
SIGN
02516412813
02516412813
3
Output:
Enter
Enter
Enter
Enter
Enter
the
the
the
the
the
passband
stopband
passband
stopband
sampling
ripple = 0.15
ripple = 60
frequency = 1500
frequency = 3000
frequency = 7000
Waveform:
02516412813
Program:
clc;
clear all;
rp = input('Enter the passband ripple = ');
rs = input('Enter the stopband ripple = ');
wp = input('Enter the passband frequency = ');
ws = input('Enter the stopband frequency = ');
fs = input('Enter the sampling frequency = ');
w1 = 2*wp/fs;
w2 = 2*ws/fs;
[n] = buttord(w1,w2,rp,rs,'s');
wn = [w1 w2];
[b,a] = butter(n,wn,'stop','s');
w = 0:0.01:pi;
[h,om] = freqs(b,a,w);
m = 20*log10(abs(h));
an = angle(h);
subplot(2,1,1);
plot(om/pi,m);
title('Magnitude Response');
ylabel('Gain in dB ---->');
xlabel('Normalised Frequency ---->');
grid on;
subplot(2,1,2);
plot(om/pi,an);
title('Phase Response');
xlabel('Normalised Frequency ---->');
ylabel('Phase in radians ---->');
grid on;
02516412813
5
Output:
Enter
Enter
Enter
Enter
Enter
the
the
the
the
the
passband
stopband
passband
stopband
sampling
ripple = 0.28
ripple = 28
frequency = 1000
frequency = 1400
frequency = 5000
Waveform:
02516412813
Program:
clc;
clear all;
rp = input('Enter the passband ripple = ');
rs = input('Enter the stopband ripple = ');
wp = input('Enter the passband frequency = ');
ws = input('Enter the stopband frequency = ');
fs = input('Enter the sampling frequency = ');
w1 = 2*wp/fs;
w2 = 2*ws/fs;
[n] = buttord(w1,w2,rp,rs);
wn = [w1 w2];
[b,a] = butter(n,wn,'bandpass','s');
w = 0:.01:pi;
[h,om] = freqs(b,a,w);
m = 20*log10(abs(h));
an = angle(h);
subplot(2,1,1);
plot(om/pi,m);
ylabel('Gain in dB ---->');
xlabel('Normalised Frequency ---->');
title('Magnitude Response');
grid on;
subplot(2,1,2);
plot(om/pi,an);
xlabel('Normalised Frequency ---->');
ylabel('Phase in Radians ---->');
title('Phase Response');
grid on;
02516412813
7
Output:
Enter
Enter
Enter
Enter
Enter
the
the
the
the
the
passband
stopband
passband
stopband
sampling
ripple = 0.36
ripple = 36
frequency = 1500
frequency = 2000
frequency = 6000
Waveform:
02516412813
02516412813
9
Output:
Enter
Enter
Enter
Enter
Enter
the
the
the
the
the
passband
stopband
passband
stopband
sampling
ripple = 0.2
ripple = 40
frequency = 2000
frequency = 3500
frequency = 8000
Waveform:
02516412813
10
11
xlabel('Normalised Frequency ---->');
grid on;
% band stop filter
b = fir1(n,wn,'stop',y);
[h,o] = freqz(b,1,256);
m = 20*log10(abs(h));
subplot(2,2,4);
plot(o/pi,m);
title('Magnitude Response of BSF');
ylabel('Gain in dB ---->');
xlabel('Normalised Frequency ---->');
grid on;
Output:
Enter
Enter
Enter
Enter
Enter
Enter
the
the
the
the
the
the
Waveform:
02516412813
12
02516412813
13
Output:
Enter the
Enter the
Enter the
Enter the
Convolved
1
Waveforms:
02516412813
14
7. Circular Convolution
Program:
clc;
clear all;
x1 = input('Enter the first sequence = ');
x2 = input('Enter the second sequence = ');
l1 = length(x1);
l2 = length(x2);
n1 = max(l1,l2);
l = l1-l2;
if(l>=0)
x2 = [x2,zeros(1,l)];
else
x1 = [x1,zeros(1,-l)];
end
%circular shifting and convolution
for n = 1:n1
y(n) = 0;
for i = 1:n1
j = n-i+1;
if(j<=0)
j = n1+j;
end
y(n) = [y(n)+x1(i)*x2(j)];
end
end
%plot the inputs and output
n = 0:n1-1;
subplot(3,1,1);
stem(n,x1);
grid on;
xlabel('Time--->');
ylabel('Amplitude--->');
title('First Sequence');
subplot(3,1,2);
stem(n,x2);
grid on;
xlabel('Time--->');
ylabel('Amplitude--->');
title('Second Sequence');
subplot(3,1,3);
disp('Convolved Sequence = ');
disp(y);
stem(n,y);
grid on;
xlabel('Time--->');
ylabel('Amplitude--->');
title('Convolved Output');
02516412813
15
Output:
Enter the
Enter the
Convolved
18
first sequence = [1 2 3 4]
second sequence = [1 2 3]
Sequence =
16
10
16
Waveforms:
02516412813
16
02516412813
17
Output:
Please enter the sequence x(n)=[1 2 3 4 5 6 7 8 9]
Please enter the length of the DFT N=6
DFT of input sequence is
Columns 1 through 4
21.0000 + 0.0000i
-3.0000 + 5.1962i
-3.0000 + 1.7321i
-3.0000 + 0.0000i
Columns 5 through 6
-3.0000 - 1.7321i
-3.0000 - 5.1962i
-0.5000 - 0.8660i
-0.5000 - 0.2887i
-0.5000 + 0.0000i
Columns 5 through 6
-0.5000 + 0.2887i
-0.5000 + 0.8660i
Waveforms:
02516412813
18
02516412813
19
Output:
Enter the sequence : [1 3 5 6 7 2 4 9 8]
x =
N =
n =
K =
1
0
wn =
2
1
3
2
4
3
7
6
8
7
0.7660 - 0.6428i
nK =
10
12
14
16
12
15
18
21
24
12
16
20
24
28
32
10
15
20
25
30
35
40
12
18
24
30
36
42
48
14
21
28
35
42
49
56
16
24
32
40
48
56
64
wNnK =
Columns 1 through 7
1.0000
1.0000
1.0000
1.0000
0.7660 - 0.6428i
0.1736 - 0.9848i
-0.5000 - 0.8660i
1.0000
-0.9397 - 0.3420i
1.0000
-0.9397 + 0.3420i
1.0000
-0.5000 + 0.8660i
1.0000
1.0000
0.1736 - 0.9848i
-0.9397 - 0.3420i
-0.5000 + 0.8660i
0.7660 + 0.6428i
0.7660 - 0.6428i
-0.5000 - 0.8660i
1.0000
-0.5000 - 0.8660i
-0.5000 + 0.8660i
1.0000 + 0.0000i
-0.5000 - 0.8660i
-0.5000 + 0.8660i
1.0000 + 0.0000i
1.0000
-0.9397 - 0.3420i
0.7660 + 0.6428i
-0.5000 - 0.8660i
0.1736 + 0.9848i
0.1736 - 0.9848i
-0.5000 + 0.8660i
1.0000
-0.9397 + 0.3420i
0.7660 - 0.6428i
-0.5000 + 0.8660i
0.1736 - 0.9848i
0.1736 + 0.9848i
-0.5000 - 0.8660i
1.0000
-0.5000 + 0.8660i
-0.5000 - 0.8660i
1.0000 + 0.0000i
-0.5000 + 0.8660i
-0.5000 - 0.8660i
1.0000 + 0.0000i
1.0000
0.1736 + 0.9848i
-0.9397 + 0.3420i
-0.5000 - 0.8660i
0.7660 - 0.6428i
0.7660 + 0.6428i
-0.5000 + 0.8660i
1.0000
0.7660 + 0.6428i
0.1736 + 0.9848i
-0.5000 + 0.8660i
-0.9397 + 0.3420i
-0.9397 - 0.3420i
-0.5000 - 0.8660i
-8.3512 +11.2381i
-6.0000 - 3.4641i
-2.0492 + 2.3309i
-2.0492 - 2.3309i
-6.0000 + 3.4641i
Columns 8 through 9
1.0000
1.0000
0.1736 + 0.9848i
0.7660 + 0.6428i
-0.9397 + 0.3420i
0.1736 + 0.9848i
-0.5000 - 0.8660i
-0.5000 + 0.8660i
0.7660 - 0.6428i
-0.9397 + 0.3420i
0.7660 + 0.6428i
-0.9397 - 0.3420i
-0.5000 + 0.8660i
-0.5000 - 0.8660i
-0.9397 - 0.3420i
0.1736 - 0.9848i
0.1736 - 0.9848i
0.7660 - 0.6428i
df =
Columns 1 through 7
45.0000
-1.5997 + 3.7110i
Columns 8 through 9
-8.3512 -11.2381i
-1.5997 - 3.7110i
02516412813
20
wn =
0.7660 + 0.6428i
nK =
0
10
12
14
16
12
15
18
21
24
12
16
20
24
28
32
10
15
20
25
30
35
40
12
18
24
30
36
42
48
14
21
28
35
42
49
56
16
24
32
40
48
56
64
wNnK =
Columns 1 through 7
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
0.7660 + 0.6428i
0.1736 + 0.9848i
-0.5000 + 0.8660i
-0.9397 + 0.3420i
-0.9397 - 0.3420i
-0.5000 - 0.8660i
1.0000
0.1736 + 0.9848i
-0.9397 + 0.3420i
-0.5000 - 0.8660i
0.7660 - 0.6428i
0.7660 + 0.6428i
-0.5000 + 0.8660i
1.0000
-0.5000 + 0.8660i
-0.5000 - 0.8660i
1.0000 - 0.0000i
-0.5000 + 0.8660i
-0.5000 - 0.8660i
1.0000 - 0.0000i
1.0000
-0.9397 + 0.3420i
0.7660 - 0.6428i
-0.5000 + 0.8660i
0.1736 - 0.9848i
0.1736 + 0.9848i
-0.5000 - 0.8660i
1.0000
-0.9397 - 0.3420i
0.7660 + 0.6428i
-0.5000 - 0.8660i
0.1736 + 0.9848i
0.1736 - 0.9848i
-0.5000 + 0.8660i
1.0000
-0.5000 - 0.8660i
-0.5000 + 0.8660i
1.0000 - 0.0000i
-0.5000 - 0.8660i
-0.5000 + 0.8660i
1.0000 - 0.0000i
1.0000
0.1736 - 0.9848i
-0.9397 - 0.3420i
-0.5000 + 0.8660i
0.7660 + 0.6428i
0.7660 - 0.6428i
-0.5000 - 0.8660i
1.0000
0.7660 - 0.6428i
0.1736 - 0.9848i
-0.5000 - 0.8660i
-0.9397 - 0.3420i
-0.9397 + 0.3420i
-0.5000 + 0.8660i
-0.9279 - 1.2487i
-0.6667 + 0.3849i
-0.2277 - 0.2590i
-0.2277 + 0.2590i
-0.6667 - 0.3849i
Columns 8 through 9
1.0000
1.0000
0.1736 - 0.9848i
0.7660 - 0.6428i
-0.9397 - 0.3420i
0.1736 - 0.9848i
-0.5000 + 0.8660i
-0.5000 - 0.8660i
0.7660 + 0.6428i
-0.9397 - 0.3420i
0.7660 - 0.6428i
-0.9397 + 0.3420i
-0.5000 - 0.8660i
-0.5000 + 0.8660i
-0.9397 + 0.3420i
0.1736 + 0.9848i
0.1736 + 0.9848i
0.7660 + 0.6428i
inversdf =
Columns 1 through 7
5.0000
-0.1777 - 0.4123i
Columns 8 through 9
-0.9279 + 1.2487i
-0.1777 + 0.4123i
>> abs(df)
ans =
02516412813
21
45.0000
4.0411
14.0013
6.9282
3.1036
3.1036
6.9282
14.0013
4.0411
1.9778
2.2099
-2.6180
2.2920
-2.2920
2.6180
-2.2099
-1.9778
1.5557
0.7698
0.3448
0.3448
0.7698
1.5557
0.4490
>> angle(df)
ans =
0
>> abs(inversdf)
ans =
5.0000
0.4490
>>
02516412813