You are on page 1of 4

Assignment No.

2
Numerical 1:
clc
d1=input('enter the value of delta
d2=input('enter the value of delta
w1=input('enter the value of omega
w2=input('enter the value of omega
T=input('enter the value of T:');
O1=2*tan(w1/2)/T;
O2=2*tan(w2/2)/T;
n1=[(1/d2^2)-1];
n2=[(1/d1^2)-1];
n3=log10(n1/n2);
n4=log10(O2/O1);
N=round((n3/n4)/2);
disp('order of filter');
N
Oc=O1/[((1/d1^2)-1)^(1/(2*N))];
b1=2*sin((1)*(3.14/(2*N)));
C0=1;
C1=1;
A=input('enter the value of A:');
b0=A/b1;
n5=b0*Oc;
h1=tf(n5,[1 C0*Oc]);
n6=b1*Oc^2;
n7=b1*Oc;
n8=C1*Oc^2;
h2=tf(n6,[1 n7 n8]);
Hs=h1*h2
Hz=c2d(Hs,T,'tustin')
[bz,az]=tfdata(Hz,'v');
w=linspace(0, pi, 50);
h=freqz(bz, az, w);
mag=abs(h);
db=20*log10(mag);
ph=phase(h);
subplot(3,1,1)
plot((w/6.28), db);
xlabel('freq');
ylabel('db');
subplot(3,1,2);
plot((w/6.28), ph);
xlabel('freq');
ylabel('phase');
subplot(3,1,3);
plot((w/6.28), mag);
xlabel('freq');
ylabel('mag');

1:');
2:');
1:');
2:');

Output:
enter the value of delta 1:.9
enter the value of delta 2:.2
enter the value of omega 1:pi/2
enter the value of omega 2:(3*pi/4)
enter the value of T:1
order of filter
N=
3
enter the value of A:1
Transfer function:
16.52
--------------------------------s^3 + 5.092 s^2 + 12.97 s + 16.52

Transfer function:
0.2332 z^3 + 0.6997 z^2 + 0.6997 z + 0.2332
------------------------------------------z^3 + 0.4394 z^2 + 0.3847 z + 0.04165

Sampling time: 1

Numerical 2:

Program:
clc
d1=input('enter the value of delta 1:');
d2=input('enter the value of delta 2:');
w1=input('enter the value of omega 1:');
w2=input('enter the value of omega 2:');
T=input('enter the value of T:');
O1=2*tan(w1/2)/T;
O2=2*tan(w2/2)/T;
n1=[(1/d2^2)-1];
n2=[(1/d1^2)-1];
n3=log10(n1/n2);
n4=log10(O2/O1);
N=round((n3/n4)/2);
disp('order of filter');
N
Oc=O1/[((1/d1^2)-1)^(1/(2*N))];
k=1:N;
s=(cos((2*k-1)*(pi/(2*N)))+(i*sin((2*k-1)*(pi/(2*N)))));
Sk=i*Oc*s
h5=tf([0.797],[1 Sk(1)]);
h6=tf([1],[1 Sk(2)]);
h7=tf([1],[1 Sk(3)]);
Hs=h5*h6*h7
Hz=c2d(Hs,T,'tustin')
[bz,az]=tfdata(Hz,'v');
w=linspace(0, pi, 50);
h=freqz(bz, az, w);
mag=abs(h);
db=20*log10(mag);
ph=phase(h);
subplot(3,1,1)
plot((w/6.28), db);
xlabel('freq');
ylabel('db');
subplot(3,1,2);
plot((w/6.28), ph);
xlabel('freq');
ylabel('phase');
subplot(3,1,3);
plot((w/6.28), mag);
xlabel('freq');
ylabel('mag');

Output:
enter the value of delta 1:.8

enter the value of delta 2:.2


enter the value of omega 1:.4*pi
enter the value of omega 2:.6*pi
enter the value of T:2
order of filter
N=
3
Sk =
-0.3998 + 0.6925i -0.7997 + 0.0000i -0.3998 - 0.6925i
Transfer function:
0.797
--------------------------------------------------------------------------------------------------s^3 - (1.599-2.22e-016i) s^2 + (1.279-5.551e-016i) s - (0.5114-3.053e-016i)

Transfer function:
(4.737+3.126e-015i) z^3 + (14.21+9.378e-015i) z^2 + (14.21+9.378e-015i) z +
(4.737 +3.126e-015i)
------------------------------------------------------------------------------------------------------------------------------------------z^3 - (9.842+7.327e-015i) z^2 + (10.62+8.882e-015i) z - (26.09+8.882e-015i)

Sampling time: 2

You might also like