0% found this document useful (0 votes)
8K views

Matlab Code For Backward Difference Discretization Method

This MATLAB code uses the backward difference discretization method to discretize an analog elliptic lowpass filter and analyze the frequency response of the resulting digital filter. It defines constants, computes coefficients for the numerator and denominator polynomials, calculates the frequency response for various sample rates, and plots the magnitude response of the analog and digital filters for comparison.

Uploaded by

A_B_C_D_Z
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8K views

Matlab Code For Backward Difference Discretization Method

This MATLAB code uses the backward difference discretization method to discretize an analog elliptic lowpass filter and analyze the frequency response of the resulting digital filter. It defines constants, computes coefficients for the numerator and denominator polynomials, calculates the frequency response for various sample rates, and plots the magnitude response of the analog and digital filters for comparison.

Uploaded by

A_B_C_D_Z
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

MATLAB CODE FOR BACKWARD DIFFERENCE DISCRETIZATION METHOD

>> 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);

>> plot(f2,h6)

>> clear all;

>> k=31.6286e-3;l=3.391e+9;m=8.15e+8;n=1.6618e+4;o=2.061e+8;p=3.61e+3;q=4.758e+8;

A=k*a^4;

B=-4*k*a^4;

C=(k*(a^2+l)*a^2+4*k*a^4+k*a^2*(a^2+m));

D=(-2*k*(a^2+l)*a^2-2*k*a^2*(a^2+m));

F=k*(a^2+l)*(a^2+m);

G=a^4;

H=((-n*a-2*a^2)*a^2+a^2*(-p*a-2*a^2));

M=((a^2+o+n*a)*a^2+(-n*a-2*a^2)*(-p*a-2*a^2)+a^2*(a^2+q+p*a));
N=((a^2+o+n*a)*(-p*a-2*a^2)+(-n*a-2*a^2)*(a^2+q+p*a));

O=(a^2+o+n*a)*(a^2+q+p*a);

num=[F D C B A];

den=[O N M H G];

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

h2=abs(h1);

h3=20*log10(h2);

hold on;

??? Undefined function or variable 'a'.

>> f=0:100:32000;

a=40000;

>> hold on;

>> plot(f,h3)

??? Undefined function or variable 'h3'.

>> k=31.6286e-3;l=3.391e+9;m=8.15e+8;n=1.6618e+4;o=2.061e+8;p=3.61e+3;q=4.758e+8;

A=k*a^4;

B=-4*k*a^4;

C=(k*(a^2+l)*a^2+4*k*a^4+k*a^2*(a^2+m));

D=(-2*k*(a^2+l)*a^2-2*k*a^2*(a^2+m));

F=k*(a^2+l)*(a^2+m);

G=a^4;

H=((-n*a-2*a^2)*a^2+a^2*(-p*a-2*a^2));

M=((a^2+o+n*a)*a^2+(-n*a-2*a^2)*(-p*a-2*a^2)+a^2*(a^2+q+p*a));
N=((a^2+o+n*a)*(-p*a-2*a^2)+(-n*a-2*a^2)*(a^2+q+p*a));

O=(a^2+o+n*a)*(a^2+q+p*a);

num=[F D C B A];

den=[O N M H G];

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

h2=abs(h1);

h3=20*log10(h2);

>> hold on;

>> plot(f,h3)

>> a=50000;

>> h12=freqz(num,den,f,'whole',50000);

h22=abs(h1);

h33=20*log10(h2);

>> hold on;

>> plot(f,h33)

>> a=60000;

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

h23=abs(h1);

h33=20*log10(h2);

hold on;

plot(f,h33)

>> a=100000;

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

h24=abs(h1);

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

plot(f,h34)

>> a=10000;

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

h24=abs(h1);

h34=20*log10(h2);

hold on;

plot(f,h34)

>> a=3000;

h15=freqz(num,den,f,'whole',3000);

h25=abs(h1);

h35=20*log10(h2);

hold on;

plot(f,h35)

>> a=500;

h16=freqz(num,den,f,'whole',500);

h26=abs(h1);

h36=20*log10(h2);

hold on;

plot(f,h36)

>> title ('Magnitude squared Response of Elliptic Lowpass Analog Filter and Digital Filter Using Mapping
of Differentials(Backward Difference)Discretization Technique')

xlabel('Frequency(rad/s)')

ylabel('Gain(dB)')

>> legend('Analog Filter','Digital Filter')

You might also like