You are on page 1of 9

MATLAB CODE FOR MATCHED Z-TRANSFORM DISCRETIZATION TECHNIQUE

>> syms a b c d k1 k2 k3 L;

>> clear all;

>> syms a b c d k1 k2 k3 L a1;

>> n1=(k1*(1-2*L*cos((k2^0.5)*a)+L^2))*(1-2*L*cos((k3^0.5)*a)+L^2);

>> n2=(1-L*(2*exp(-a1*a)*cos(b*a))+exp(-2*a1*a)*L^2)*(1-L*(2*exp(-c*a)*cos(d*a))+exp(-2*c*a)*L^2);

collect(n1,L)

ans =

k1*L^4 + (- 2*k1*cos(a*k2^(1/2)) - 2*k1*cos(a*k3^(1/2)))*L^3 + (2*k1 +


4*k1*cos(a*k2^(1/2))*cos(a*k3^(1/2)))*L^2 + (- 2*k1*cos(a*k2^(1/2)) - 2*k1*cos(a*k3^(1/2)))*L + k1

>> A4=k1;

A3= (- 2*k1*cos(a*k2^(1/2)) - 2*k1*cos(a*k3^(1/2)));

A2=(2*k1 + 4*k1*cos(a*k2^(1/2))*cos(a*k3^(1/2)));

A1= (- 2*k1*cos(a*k2^(1/2)) - 2*k1*cos(a*k3^(1/2)));

A0= k1;

collect(n2,L)

ans =

(1/(exp(2*a*a1)*exp(2*a*c)))*L^4 + (- (2*cos(a*b))/(exp(a*a1)*exp(2*a*c)) -
(2*cos(a*d))/(exp(2*a*a1)*exp(a*c)))*L^3 + (1/exp(2*a*a1) + 1/exp(2*a*c) +
(4*cos(a*b)*cos(a*d))/(exp(a*a1)*exp(a*c)))*L^2 + (- (2*cos(a*b))/exp(a*a1) - (2*cos(a*d))/exp(a*c))*L
+1
>> B4=(1/(exp(2*a*a1)*exp(2*a*c)));

B3=(- (2*cos(a*b))/(exp(a*a1)*exp(2*a*c)) - (2*cos(a*d))/(exp(2*a*a1)*exp(a*c)));

B2=(1/exp(2*a*a1) + 1/exp(2*a*c) + (4*cos(a*b)*cos(a*d))/(exp(a*a1)*exp(a*c)));

B1=(- (2*cos(a*b))/exp(a*a1) - (2*cos(a*d))/exp(a*c));

B0= 1;

>> clear a b c d k1 k2 k3 L a1;

>> a=2.5e-5;

f=0:100:32000;

b=11707.406

b=

1.1707e+004

>> c=1.805e+3;d=2.1738e+3;k1=31.6286e-3;k2=3.391e+9;k3=8.15e+8;

A4=k1;

A3= (- 2*k1*cos(a*k2^(1/2)) - 2*k1*cos(a*k3^(1/2)));

A2=(2*k1 + 4*k1*cos(a*k2^(1/2))*cos(a*k3^(1/2)));

A1= (- 2*k1*cos(a*k2^(1/2)) - 2*k1*cos(a*k3^(1/2)));

A0= k1;

num=[A0 A1 A2 A3 A4];

>> a1=8308.83;

B4=(1/(exp(2*a*a1)*exp(2*a*c)));

B3=(- (2*cos(a*b))/(exp(a*a1)*exp(2*a*c)) - (2*cos(a*d))/(exp(2*a*a1)*exp(a*c)));

B2=(1/exp(2*a*a1) + 1/exp(2*a*c) + (4*cos(a*b)*cos(a*d))/(exp(a*a1)*exp(a*c)));


B1=(- (2*cos(a*b))/exp(a*a1) - (2*cos(a*d))/exp(a*c));

B0= 1;

den=[B0 B1 B2 B3 B4];

h1=freqz(num,den,f,'whole',40000);

h2=abs(h1);

h3=20*log10(h2);

hold on;

plot(f,h3)

>> clear all;

>> K=[31.6286e-3 3.391e+9 8.15e+8 1.6618e+4 2.061e+8 3.61e+3 4.758e+8];

u=[K(1) 0 (K(1)*K(2))];

v=[1 0 K(3)];

w=[1 K(4) K(5)];

x=[1 K(6) K(7)];

num=conv(u,v);

num1=conv(u,v);

den2=conv(w,x);

f1=0:100:201062;

f2=f1/(2*pi);

h4=freqs(num1,den2,f1);

h5=abs(h4);

h6=20*log10(h5);

>> hold on;

>> plot(f,h6)

??? Undefined function or variable 'f'.


>> plot(f2,h6)

>> a=1.6667e-5;

f=0:100:32000;

b=11707.406

b=

1.1707e+004

c=1.805e+3;d=2.1738e+3;k1=31.6286e-3;k2=3.391e+9;k3=8.15e+8;

A4=k1;

A3= (- 2*k1*cos(a*k2^(1/2)) - 2*k1*cos(a*k3^(1/2)));

A2=(2*k1 + 4*k1*cos(a*k2^(1/2))*cos(a*k3^(1/2)));

A1= (- 2*k1*cos(a*k2^(1/2)) - 2*k1*cos(a*k3^(1/2)));

A0= k1;

num=[A0 A1 A2 A3 A4];

a1=8308.83;

B4=(1/(exp(2*a*a1)*exp(2*a*c)));

B3=(- (2*cos(a*b))/(exp(a*a1)*exp(2*a*c)) - (2*cos(a*d))/(exp(2*a*a1)*exp(a*c)));

B2=(1/exp(2*a*a1) + 1/exp(2*a*c) + (4*cos(a*b)*cos(a*d))/(exp(a*a1)*exp(a*c)));

B1=(- (2*cos(a*b))/exp(a*a1) - (2*cos(a*d))/exp(a*c));

B0= 1;

den=[B0 B1 B2 B3 B4];

h1=freqz(num,den,f,'whole',60000);
h2=abs(h1);

h3=20*log10(h2);

hold on;

b=

1.1707e+004

??? b =

Error: Expression or statement is incomplete or incorrect.

>> plot(f2,h6)

a=1.6667e-5;

f=0:100:32000;

b=11707.406

b=

1.1707e+004

>> plot(f2,h6)

a=1.6667e-5;

f=0:100:32000;

b=11707.406
b=

1.1707e+004

>> a=1.6667e-5;

f=0:100:32000;

b=11707.406;

>> c=1.805e+3;d=2.1738e+3;k1=31.6286e-3;k2=3.391e+9;k3=8.15e+8;

A4=k1;

A3= (- 2*k1*cos(a*k2^(1/2)) - 2*k1*cos(a*k3^(1/2)));

A2=(2*k1 + 4*k1*cos(a*k2^(1/2))*cos(a*k3^(1/2)));

A1= (- 2*k1*cos(a*k2^(1/2)) - 2*k1*cos(a*k3^(1/2)));

A0= k1;

num=[A0 A1 A2 A3 A4];

a1=8308.83;

B4=(1/(exp(2*a*a1)*exp(2*a*c)));

B3=(- (2*cos(a*b))/(exp(a*a1)*exp(2*a*c)) - (2*cos(a*d))/(exp(2*a*a1)*exp(a*c)));

B2=(1/exp(2*a*a1) + 1/exp(2*a*c) + (4*cos(a*b)*cos(a*d))/(exp(a*a1)*exp(a*c)));

B1=(- (2*cos(a*b))/exp(a*a1) - (2*cos(a*d))/exp(a*c));

B0= 1;

den=[B0 B1 B2 B3 B4];

h1=freqz(num,den,f,'whole',60000);

h2=abs(h1);

h3=20*log10(h2);
hold on;

>> plot(f,h3)

>> a=1e-5;

f=0:100:32000;

b=11707.406;

c=1.805e+3;d=2.1738e+3;k1=31.6286e-3;k2=3.391e+9;k3=8.15e+8;

A4=k1;

A3= (- 2*k1*cos(a*k2^(1/2)) - 2*k1*cos(a*k3^(1/2)));

A2=(2*k1 + 4*k1*cos(a*k2^(1/2))*cos(a*k3^(1/2)));

A1= (- 2*k1*cos(a*k2^(1/2)) - 2*k1*cos(a*k3^(1/2)));

A0= k1;

num=[A0 A1 A2 A3 A4];

a1=8308.83;

B4=(1/(exp(2*a*a1)*exp(2*a*c)));

B3=(- (2*cos(a*b))/(exp(a*a1)*exp(2*a*c)) - (2*cos(a*d))/(exp(2*a*a1)*exp(a*c)));

B2=(1/exp(2*a*a1) + 1/exp(2*a*c) + (4*cos(a*b)*cos(a*d))/(exp(a*a1)*exp(a*c)));

B1=(- (2*cos(a*b))/exp(a*a1) - (2*cos(a*d))/exp(a*c));

B0= 1;

den=[B0 B1 B2 B3 B4];

h1=freqz(num,den,f,'whole',100000);

h2=abs(h1);

h3=20*log10(h2);

hold on;

>> plot(f,h3)

>> a=1e-4;
f=0:100:32000;

b=11707.406;

c=1.805e+3;d=2.1738e+3;k1=31.6286e-3;k2=3.391e+9;k3=8.15e+8;

A4=k1;

A3= (- 2*k1*cos(a*k2^(1/2)) - 2*k1*cos(a*k3^(1/2)));

A2=(2*k1 + 4*k1*cos(a*k2^(1/2))*cos(a*k3^(1/2)));

A1= (- 2*k1*cos(a*k2^(1/2)) - 2*k1*cos(a*k3^(1/2)));

A0= k1;

num=[A0 A1 A2 A3 A4];

a1=8308.83;

B4=(1/(exp(2*a*a1)*exp(2*a*c)));

B3=(- (2*cos(a*b))/(exp(a*a1)*exp(2*a*c)) - (2*cos(a*d))/(exp(2*a*a1)*exp(a*c)));

B2=(1/exp(2*a*a1) + 1/exp(2*a*c) + (4*cos(a*b)*cos(a*d))/(exp(a*a1)*exp(a*c)));

B1=(- (2*cos(a*b))/exp(a*a1) - (2*cos(a*d))/exp(a*c));

B0= 1;

den=[B0 B1 B2 B3 B4];

h1=freqz(num,den,f,'whole',10000);

h2=abs(h1);

h3=20*log10(h2);

hold on;

>> plot(f,h3)

>> title ('Magnitude squared Response of Elliptic Lowpass Analog Filter and Digital Filter Using Matched
Z-Transform Discretization Technique')

xlabel('Frequency(Hz)')

ylabel('Gain(dB)')
legend('Analog Filter','Digital Filter with Fs=40kHz','Digital Filter with Fs=60kHz','Digital Filter with
Fs=100kHz','Digital Filter with Fs=10kHz' )

>> legend('Digital Filter with Fs=40kHz','Analog Filter','Digital Filter with Fs=60kHz','Digital Filter with
Fs=100kHz','Digital Filter with Fs=10kHz' )

>>

You might also like