+ All Categories
Home > Documents > Dsp Lab File

Dsp Lab File

Date post: 28-Nov-2014
Category:
Upload: avinash-jha
View: 192 times
Download: 2 times
Share this document with a friend
51
INDEX Exp No. Experiment Name Date of Performan ce Date of Checkin g Signatu re Marks (10) 1. Program for generation of sin, cos, exponential, unit impulse, step function, square wave 2. a) Program to determine convolution of two sequences b) Program to determine correlation of two sequences 3. To calculate DTFT & plot magnitude & phase response of following sequence x(n) = 1 0=<n<=3 = 0 elsewhere 4. An LTI system is specified by the difference equation Y(n)=0.9*y(n-1)+x(n) a) Determine H(exp(jw)) b) Calculate & plot the steady state response Y(n) to X(n) = cos(0.5 n)u(n)
Transcript
Page 1: Dsp Lab File

INDEX

Exp No.

Experiment Name Date ofPerformance

Date of Checking

Signature Marks(10)

1. Program for generation of sin, cos, exponential, unit impulse, step function, square wave

2. a) Program to determine convolution of two sequences

b) Program to determine correlation of two sequences

3. To calculate DTFT & plot magnitude & phase response of following sequence

x(n) = 1 0=<n<=3 = 0 elsewhere

4. An LTI system is specified by the difference equation

Y(n)=0.9*y(n-1)+x(n)

a) Determine H(exp(jw))b) Calculate & plot the steady state response

Y(n) to X(n) = cos(0.5∏n)u(n)5. Given a causal system

Y(n) = 0.9*y(n-1)+x(n)

a) Find H(2) & sketch its pole zero plotb) Plot H(w) & angle H(w)

6. Let X(n) be a 4–point sequenceX(n) = 1 0<n<3 = 0 elsewherecompute the 4-point, 8-point, 16-point DFT & plot magnitude & phase plot

7. Differentiate b/w high density high resolution spectrum, for given sequence

Page 2: Dsp Lab File

X(n)=cos(0.48*pi*n)+cos(0.52*pi*n)

a) Determine DFT & also plot it for 0<=n<=10 & 0<=n<=100

8. Program to find the circular convolution of two sequences x(n) & h(n)

9. To design a FIR LPL filter using Rectangular, Barlett, Hamming, Hanning, Blackmann Window & plot the phase response of filter. The specification of the filter are as follows:

Wp=0.5*pi, Ws=0.3*pi, 0.25dB, As=50 dB

10. Transform H(s)=(s+1)/(s2+5s+6) into a digital filter using

a) Impulse Invariant Transformationb) Bilinear Transformation

EXPERIMENT No. – 1

AIM

Page 3: Dsp Lab File

Program for generation of sin, cos, exponential, unit impulse, step function, square wave.

THEORY

Sine Function:

A function f(x)=sin(x) is a periodic function with a period of 2∏, it will form a periodic wave after 2∏. The f(x) will lie between -1 to +1.

Cosine Function:

A function f(x)=cos(x) is a periodic function with a period of 2∏, it will form a periodic wave after 2∏.

Exponential Function:

A function f(x)=ex is defined as:

0<f(x)≤1; for -∞≤x≤01≤f(x)<∞; for 0≤x≤∞

Unit impulse Function:

Unit impulse is a signal that is 0 everywhere except at n=0 where it is 1. In discrete time domain the unit impulse signal is defined as:

∂(n) =1; n=0 = 0; elsewhere

Unit Step Function:

The integral of the impulse function is a unit step signal. In discrete time unit step signal is defined as:

U(n) =1; n>=0 = 0; n<0

Square Wave Function:

It is a periodic function with a period of T. If f(x) is a square wave function thenF(x) = 1; 0<x<T/2 = -1; T/2<x<T

CODE:

t=0:0.01:pi;

Page 4: Dsp Lab File

x=sin(2*pi*t);y=cos(2*pi*t);z1=exp(2* t);z2=exp(2*(-t));subplot(221);plot(x);xlabel('Time');ylabel('Amplitude');title('Cosine Wave');subplot(223);plot(z1);xlabel('Time');ylabel('Amplitude');title('Exponential Rising');subplot(224);plot(z2);xlabel('Time');ylabel('Amplitude');title('Exponential Falling');h(5)=1;for i=1:4 h(i)=0;end;for i=6:10 h(i)=0;end;m=-4:5;figure;subplot(221);stem(m,h);xlabel('Time');ylabel('Amplitude');title('Unit Impulse');for j=1:4 g(j)=0;end;for j=5:10 g(j)=1;end;subplot(212);stem(m,g);xlabel('Time');yabel('Amplitude');title('Step Function');a=1;b=5;c=6;d=10;for p=1:4 for k=a:b s(k)=1;

Page 5: Dsp Lab File

end; for k=c:d s(k)=-1; end; a=a+10; b=b+10; c=c+10; d=d+10;end;n=0:39;figure;subplot(211);stem(n,s);xlabel('Time');ylabel('Amplitude');title('Square Wave');v=0:5;subplot(212);stem(v,v);xlabel('Time');ylabel('Amplitude');title('Ramp');

OUTPUT

Page 6: Dsp Lab File

EXPERIMENT No. – 2(a)

AIM

Page 7: Dsp Lab File

To generate convolved output of two sample sequences.

THEORY

A convolution is an integral that expresses the amount of overlap of one function as it is shifted over another function. It therefore “blends” from one function to another. For example, in synthesis imaging, the measured dirty map is a convolution of the “true” CLEAN map with the dirty beam.

This formula gives response y(n) of the LTI system as a function of the input signal x(n) and the unit sample response h(n) is called CONVOLUTION SUM.

We say that the input x(n) is convolved with the impulse response h(n) to yield the output y(n).

The process of computing the convolution between x(k) and h(k) involves the following steps:

1. Folding: Fold h(k) about k=0 to obtain h(-k).

2. Shifting: Shift h(-k) by n to the right(left) if n is positive(negative) to obtain h(n-k).

3. Multiplication: Multiply x(k) by h(n-k) to obtain the value of the output sequence v(k) = x(k)h(n-k).

4. Summation: Sum all the values of the product sequence v(k) to obtain the value of the output at a given time .

PROPERTIES OF CONVOLUTION

1. COMMUTATIVE LAW: x(n)*h(n) = h(n)* x(n)

2. ASSOCIATIVE LAW: [x(n)*h1(n)]*h2(n) = x(n)*[h1(n)*h2(n)]

3. DISTRIBUTIVE LAW: x(n)*[h1(n)+h2(n)] = x(n)*h1(n) + x(n)*h2(n)

CODE:

x=[1 1 1 1 1 0 0 0 0 0 0 0 0 0]

Y(n)= ∑ x(k)h(n-k)

Page 8: Dsp Lab File

h=[1 1 1 1 1 0 0 0 0 0 0 0 0 0]k1=0;k2=0;k3=4;k4=4;ley=k1+k2;rey=k3+k4;for n=(ley:rey)n1=n+1;y(n1)=0;for k=k1:(n-k2) a=k+1; b=(n-k)+1;if b<=0break;endy(n1)=y(n1)+((x(a)).*(h(b)));endendn=ley:rey;figure;stem(n,y);Xlabel('Time');Ylabel('Amplitude');Title('Convolved Output');

OUPTUT

Page 9: Dsp Lab File

EXPERIMENT No. – 2(b)

Page 10: Dsp Lab File

AIM

To determine the correlation of two sequences.

THEORY:

Suppose that we have two signal sequences x(n) and y(n) each of which has finite energy.The cross correlation of x(n) and y(n) is a sequence rxy(l), which is defined as

r xy (l) = x(n) y(n-l)

or equivalently as

r xy (l) = x(n+l) y(n)

the index l is the time shift (or lag) parameter and the subscript xy on the cross correlation sequence r xy (l) indicates the sequence being correlated. The order of the subscript, with x preceding y, indicates the direction in which one sequence is shifted relative to other.

If we reverse the role of x(n) and y(n) in above equation we obtain the correlation sequence

r yx (l) = y(n) x(n-l)

or equivalently as

r yx (l) = y(n+l) x(n)

by comparing the equations

r xy (l) = r yx (-l)

therefore r yx (l) is simply folded version of r xy (l) where the folding is done with respect to l=0.In the special case where y(n)=x(n) , we have AUTOCORRELATION of x(n) which is defined as the sequence

r xx (l) = x(n) x(n-l)

or equivalently as

r xx (l) = x(n+l) x(n)

CONCLUSION: The convolution of two discrete time signals has been found resultant signal is shown wave form.

CODE:

Page 11: Dsp Lab File

x=[2 -1 3 7 1 2 -3 0 0 0 0 0 0 0];y=[0 0 0 0 0 0 0 0 0 1 -1 2 -2 4 1 -2 5];h=fliplr(y);k1=-4;k2=-3;k3=2;k4=4;ler=k1+k2;rey=k3+k4;for n=ler:rey n1=n+8; r(n1)=0; for k=k1:(n1-k2) a=k+5; b=(n-k)+4; if b<=0 break; end r(n1)=r(n1)+((x(a)).*(h(b))); end end n=ler:rey; stem(n,r); xlabel('time'); ylabel('amplitude'); title('correlated output->y');

OUTPUT

Page 12: Dsp Lab File

EXPERIMENT No.- 3

Page 13: Dsp Lab File

AIM

To determine DTFT of a given sequence

CODE:

sum=0;p=1;x=[1 1 1 1];for w = 0: (pi/100) : (2*pi) sum=0;for i=0:3 y=x(i+1)*exp(-j*w*i); sum=sum+y;end X(p)=sum; p=p+1;endt=0:0.01:2subplot(211);plot(t,abs(X));title('Magnitude Plot');subplot(212);plot(t,phase(X));title('Phase Plot');

Page 14: Dsp Lab File

OUTPUT

EXPERIMENT No.- 4

AIM

Page 15: Dsp Lab File

An LTI system is specified by the difference equationY(n)=0.8*Y(n-1)+x(n)

(a) Determine H(exp(jw))(b) Calculate & plot the steady state response

Yss (n) to x(n)=cos(0.5∏n) u(n)

THEORY

Y(n) = 0.8Y(n-1)+x(n)

Taking DTFT

Y(ejw) = 0.8 e-jwY(ejw) + x(ejw)

Hence

H(w) = Y(ejw)/x(ejw) = 1/[1-0.8 ejw]

Now,

Y(n)=x(n)*h(n)

Y(n)=∑ h(k).x(n-k)

Here,

Y(n)= cos(0.5∏n)u(n), then

Y(n)=4.029 cos(0.5∏(n-3.4321))

CODE:

n=0:100;

Page 16: Dsp Lab File

x=cos(0.05*pi*n);y=0.0927*cos(0.05*pi*(n-3.4231));figure;subplot(211);stem(n,x);title('input');subplot(212);stem(n,y);title('output');

Output

EXPERIMENT No. - 5

Page 17: Dsp Lab File

AIM

Given a causal systemy(n)=0.9y(n-1)+x(n)

(a) Find H(z) & sketch its pole - zero plot(b) Plot magnitude & angle of H(exp(jw)) (c) Comment on the stability of the system

THEORY

The given difference equation is,

y(n)=0.9*y(n-1)+x(n)

Now, taking z-transform we get,

Y(z)-0.9*z-1Y(z)=X(z)Or, Y(z)[1-0.9*z-1]=X(z)

This gives,

H(z)=1/(1-0.9z-1)

The pole of the system is lying at, z=0.9, which is inside the unit circle. Also, the condition for stability is that poles must lie inside the circle for the system to be stable. Here, the pole z=0.9 is lying inside of the unit circle. So, the system is stable.

CODE:

zplane(0,0.09);

Page 18: Dsp Lab File

k=1;for w=0:0.01:(2*pi); h(k)=1/(1-(0.9*exp(-j*w))); k=k+1;end;w=0:0.01:(2*pi);figure;subplot(211);plot(w,abs(h));title('magnitude of h(e(jw))');subplot(212);plot(w,angle(h));title('angle of h(e(jw))');

OUTPUT

Page 19: Dsp Lab File

EXPERIMENT NO.6

Page 20: Dsp Lab File

AIM:

Let x(n) be 4 point sequence

X(n)=1 ; 0=< n =<3

=0 ; elsewhere

Compute the 4-point DFT, 8-point DFT, and 16-point DFT and plot their magnitude and phase plot.

THEORY:

The discrete Fourier transform computes the values of the z transform for evenly spaced points around the unit circle for a given sequence.

If the sequence to be represented is of finite duration, i.e., has only a finite number of non-zero values, the transform is discrete Fourier transform.

N-1

X(k) = ∑ x(n) e-j2kn/N

n=0

k = 0,1,2…………..,N-1

x(n) = {1,1,1,1}

4-point DFT

N = 4

N-1

X(k ) = ∑ x(n) e-j2kn/N

n=0

k = 0,1,2…………..,N-1

3

X(k) = ∑ x(n) e-j2kn/4

n=0

k = 0,1,2,3

X(k) = x(0)+x(1) e-j2k/4 +x(2) e-j2k2/4 +x(3) e-j2k3/4

X(0) = 1+1+1+1=4

X(1) = 1+ e-j2/4 +e-j22/4 +e-j23/4

= 0

X(2) = 1+ e-j2/4 +e-j24/4 +e-j26/4

= 0

Page 21: Dsp Lab File

X(3) = 1+ e-j2/4 +e-j26/4 +e-j29/4

= 0

8-point DFT

N = 8

X(n) = {1,1,1,1,0,0,0,0}

N-1

X(k) = ∑ x(n) e-j2kn/N

n=0

k = 0,1,2…………..,N-1

7

X(k) = ∑ x(n) e-j2kn/8

n=0

k = 0,1,2,3,4,5,6,7

X(k) = x(0)+x(1) e-j2k/8 +x(2) e-j2k2/8 +x(3) e-j2k3/8+x(4) e-j2k4/8

+x(5) e-j2k5/8 +x(6) e-j2k6/8+x(7) e-j2k7/8

X(k) = 1+x(1) e-j2k/8 +x(2) e-j2k2/8 +x(3) e-j2k3/8

X(0) = 1+1+1+1 = 4

X(1) = 1+ e-j2/8 +e-j22/8 +e-j23/8

= 1-2.414j

X(2) = 1+ e-j2/4 +e-j24/4 +e-j26/4

= 0

X(3) = 1+ e-j2/8 +e-j26/8 +e-j29/8

= 1-0.414j

X(4) = 1+ e-j2/8 +e-j2/8 +e-j2

= 0

X(5) = 1+ e-j2/8 +e-j2+e-j2

= 1+0.414j

X(6) = 1+ e-j2+e-j2+e-j2

= 0

X(7) = 1+ e-j2+e-j2+e-j2

= 1+2.414j

16point DFT

N = 16

Page 22: Dsp Lab File

X(n) = {1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0}

N-1

X(k) = ∑ x(n) e-j2kn/N

n=0

k = 0,1,2…………..,N-1

15

X(k) = ∑ x(n) e-j2kn/16

n=0

k = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15

X(k) = 1+x(1) e-j2k/16+x(2) e-j2k2/16+(3) e-j2k3/16

X(0) = 1+1+1+1 = 4

X(1) = 1+ e-j2/16+e-j22/16+e-j23/16

= 3.007-2.007j

X(2) = 1+ e-j2/16+e-j24/16+e-j26/16

= 1-2.414j

X(3) = 1+ e-j2/16+e-j26/16+e-j29/16

= 1.593-1.247j

X(4) = 1+ e-j2/16+e-j2/16+e-j2

= 0

X(5) = 1+ e-j2/16+e-j2+e-j2

= 0.833+0.167j

X(6) = 1+ e-j2+e-j2+e-j2

= 0

X(7) = 1+ e-j2+e-j2+e-j2

= 1.166-2.012j

X(8) = 1+ e-j2/16+e-j2/16+e-j2/16

= 0

X(9) = 1+ e-j2/16+e-j2/16+e-j2

= 0.407+0.593j

X(10) = 1+ e-j2/16+e-j2+e-j2

= 1+0.414j

X(11) = 1+ e-j2/+e-j2+e-j2

= 0.833-0.167j

Page 23: Dsp Lab File

X(12) = 1+ e-j2/+e-j2+e-j2

= 0

X(13) = 1+ e-j2/16+e-j2+e-j2

= -0.247+1.247j

X(14) = 1+ e-j2/+e-j2+e-j2

= 1+j

X(15) = 1+ e-j2/+e-j2+e-j2

= 3.007+2.007j

CODE:

x= [1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0];N4=4;for k=0: N4-1 k1=k+1;

Page 24: Dsp Lab File

y4 (k1) =0; for n=0 : 3 n1=n+1; y4 (k1) =y4 (k1) + ((x (n1)) .* (exp (-j*(2*pi*k*n)/N4))); endendN8=8;for k=0 : N8-1 k1=k+1; y8 (k1) =0; for n=0: 3 n1=n+1; y8 (k1) =y8 (k1) + ((x (n1)) .* (exp (-j*(2*pi*k*n)/N8))); endendN16=16;for k=0 : N16-1 k1=k+1; y16 (k1) =0; for n=0 : 3 n1=n+1; y16 (k1) =y16 (k1) + ((x (n1)) .* (exp (-j*(2*pi*k*n)/N16))); endendk4=0 : N4-1;figure;subplot (211);stem (k4, abs (y4));title (‘magnitude of 4-point DFT’);subplot (212);stem (k4, angle (y4));title (‘angle of 4-point DFT’);k8=0 : N8-1;figure;subplot (211);stem (k8, abs (y8));title (‘magnitude of 8-point DFT’);subplot (212);stem (k8, angle (y8));title (‘angle of 8-point DFT’);k16=0 : N16-1;figure;subplot (211);stem (k16, abs (y16));title (‘magnitude of 16-point DFT’);subplot (212);stem (k16, angle (y16));title (‘angle of 16-point DFT’);

Page 25: Dsp Lab File

OUTPUT:

Page 26: Dsp Lab File

0 0.5 1 1.5 2 2.5 30

1

2

3

4magnitude of 4-point DFT

0 0.5 1 1.5 2 2.5 3-3

-2

-1

0angle of 4-point DFT

Page 27: Dsp Lab File

0 1 2 3 4 5 6 70

1

2

3

4magnitude of 8-point DFT

0 1 2 3 4 5 6 7-4

-2

0

2angle of 8-point DFT

Page 28: Dsp Lab File

0 5 10 150

1

2

3

4magnitude of 16-point DFT

0 5 10 15-4

-2

0

2angle of 16-point DFT

CONCLUSION:

The magnitude and phase of 4-point, 8-point, 16-point DFT has been computed and is shown in figure.

EXPERIMENT NO.7(a)

AIM

Page 29: Dsp Lab File

Differentiate between high density high resolutions spectrums. For given sequence:

X(n)=cos(0.48*pi*n) + cos(0.52*pi*n)

Determine DFT & also plot it for 0<=n<=10

CODE:

n=0:10x=cos(0.48*pi*n)+cos(0.52*pi*n);p=1;N=11;for w=0:pi/100:2*pi; sum=0; for n=0:N-1; sum=sum+(x(n+1)*exp(-j*w*n)); end y(p)=sum; p=p+1;endfigure;magx=abs(y);phasex=angle(y);subplot(311);stem(x);xlabel('x--> ');ylabel('y-->');subplot(312);plot(magx);xlabel('x--->');ylabel('y--->');subplot(313);plot(phasex);xlabel('x--->');ylabel('y--->');

OUTPUT

Page 30: Dsp Lab File

EXPERIMENT NO.7(b)

AIM

Page 31: Dsp Lab File

Differentiate between high density high resolutions spectrums. For given sequence:

X(n)=cos(0.48*pi*n) + cos(0.52*pi*n)

Determine DFT & also plot it for 0<=n<=100

CODE:

n=0:100x=cos(0.48*pi*n)+cos(0.52*pi*n);p=1;N=101;for w=0:pi/100:2*pi; sum=0; for n=0:N-1; sum=sum+(x(n+1)*exp(-j*w*n)); end y(p)=sum; p=p+1;endfigure;magx=abs(y);phasex=angle(y);subplot(311);stem(x);xlabel('x--> ');ylabel('y-->');subplot(312);plot(magx);xlabel('x--->');ylabel('y--->');subplot(313);plot(phasex);xlabel('x--->');ylabel('y--->');

OUTPUT

Page 32: Dsp Lab File

EXPERIMENT No. – 8

AIM

Program to find circular convolution of two sequences x(n) & h(n)

Page 33: Dsp Lab File

CODE:

x = [1 2 2 0]

h = [1 2 3 4]length_x = length(x);length_h = length(h);if length_x ~= length_h; rest = abs(length_x - length_h); a = zeros(1,rest); if length_x > length_h; h = [h,a] length_h = length(h); else x = [x,a] length_x = length(x); end;end;for n = 1 : length_x; sum = 0; for m = 1 : length_x; if (n-m+1) < 1; t = n-m+length_x+1; else t = n-m+1; end; sum = sum + (x(m) * h(t)); end; result(n) = sum;end;resultfigure(1);subplot(3,1,1);stem(x);xlabel('n ----->');ylabel('x(n) ----->');subplot(3,1,2);stem(h);xlabel('n ----->');ylabel('h(n) ----->');subplot(3,1,3);stem(result);xlabel('n ----->');ylabel('y(n) ----->');

OUTPUT

Page 34: Dsp Lab File

EXPERIMENT No.-9

Page 35: Dsp Lab File

AIM

To design a FIR low pass filter using Rectangular, Barlett, Hamming, Hanning & Blackmann window & to plot the frequency response of filter. The specification of the filter are as follows:

Wp=0.2*pi, Ws=0.3*pi, As=50db, Ap=0.25 db

THEORY

The Image Processing Toolbox supports one class of linear filter, the two-dimensionalfinite impulse response (FIR) filter. FIR filters have several characteristics that makethem ideal for image processing in the MATLAB environment:

FIR filters are easy to represent as matrices of coefficients.Two-dimensional FIR filters are natural extensions of one-dimensional FIRfilters.There are several well-known, reliable methods for FIR filter design.FIR filters are easy to implement.FIR filters can be designed to have linear phase, which helps prevent distortion.

Another class of filter, the infinite impulse response (IIR) filter, is not as suitable forimage processing applications. It lacks the inherent stability and ease of design and implementation of the FIR filter. Therefore, this toolbox does not provide IIR filter support.

Windowing Method

The windowing method involves multiplying the ideal impulse response with a windowfunction to generate a corresponding filter. Like the frequency sampling method, thewindowing method produces a filter whose frequency response approximates a desiredfrequency response. The windowing method, however, tends to produce better resultsthan the frequency sampling method.

The toolbox provides two functions for window-based filter design, fwind1 andfwind2. fwind1 designs a two-dimensional filter by using a two-dimensional windowthat it creates from one or two one-dimensional windows that you specify. fwind2designs a two-dimensional filter by using a specified two-dimensional window directly.

fwind1 supports two different methods for making the two-dimensional windows ituses:

Transforming a single one-dimensional window to create a two-dimensionalwindow that is nearly circularly symmetric, by using a process similar to rotation

Creating a rectangular, separable window from two one-dimensional windows,by computing their outer product

CODE:

Page 36: Dsp Lab File

ws=.3wp=.2as=50rp=.25dp=(1-exp(-rp/20))/(1+exp(-rp/20));ds=exp(-as/20)+dp*exp(-rp/20);num=-20*log10(sqrt(dp*ds))-13;den=(14.6*(ws-wp))/2*pi;N=ceil(num/den);tr=ws-wp;M=(4*pi)/tr;wc=(ws+wp)/2;alpha=(M-1)/2;hd=sin(wc*(M-alpha))/(pi*(M-alpha));A=boxcar(M);h=hd*A;figure(1);freqz(h);M=(8*pi)/tr;hd=sin(wc*(M-alpha))/(pi*(M-alpha));A=hamming(M);h=hd*A;figure(2);freqz(h);M=(8*pi)/tr;hd=sin(wc*(M-alpha))/(pi*(M-alpha));A=hanning(M);h=hd*A;figure(3);freqz(h);M=(8*pi)/tr;hd=sin(wc*(M-alpha))/(pi*(M-alpha));A=bartlett(M);h=hd*A;figure(4);freqz(h);M=(12*pi)/tr;hd=sin(wc*(M-alpha))/(pi*(M-alpha));A=blackman(M);h=hd*A;figure(5);freqz(h);

OUTPUT

Page 37: Dsp Lab File
Page 38: Dsp Lab File

EXPERIMENT No. - 10

Page 39: Dsp Lab File

AIM

Transform H(s) = (s+1)/(s2+5s+6) into a digital filter using:

(a) Impulse Invariant Transformation(b) Bilinear Transformation

THEORY

Impulse Invariant Transformation

In this technique the desired impulse response of the digital filter is obtained by uniformly sampling the impulse response of the analog filter.

H(s) = (s+1)/(s2+5s+6)

H(z) = (1-0.8966z-1)/(1-1.5595 z-1+0.66065 z-1)

Bilinear Transformation

In this technique the desired impulse response of the digital filter is obtained uniformly sampling the impulse response of the analog filter.

H(s) = (s+1)/ (s2+5s+6)

Taking T=1sec.

H(z)=(0.15-0.1z-1-0.05z-2)/(1+0.2z-1)

CODE:

Page 40: Dsp Lab File

****************************** Impulse Invariant Method******************************

T=0.1;c=[1 1];d=[1 5 6];[r p k]=residue(c,d);p=exp(p*T);[b a]=residuez(r,p,k);b=real(b);a=real(a);

****************************** Bilinear Transformation Method ******************************

c=[1 1]d=[1 5 6]T=1Fs=1/T[b,a]=bilinear(c,d,Fs)

Output

****************************** Impulse Invariant Method ******************************

T = 0.1000

c = 1 1

d = 1 5 6

Page 41: Dsp Lab File

r = 2.0000 -1.0000

p = -3.0000 -2.0000

k = []

p = 0.7408 0.8187

b = 1.0000 -0.8966

a = 1.0000 -1.5595 0.6065

b = 1.0000 -0.8966

a = 1.0000 -1.5595 0.6065

****************************** Bilinear Transformation Method ******************************

c = 1 1

d = 1 5 6

T = 1

Fs = 1

b = 0.1500 0.1000 -0.0500a = 1.0000 0.2000 -0.0000


Recommended