You are on page 1of 15

# DIGITAL SIGNAL PROCESSING LABORATORY – 10MTL78

DIGITAL SIGNAL PROCESSING LABORATORY 10MTL78
CONTENTS
PART A: MATLAB
PROGRAM 01: GENERATION OF BASIC SIGNALS PROGRAM 02: LINEAR CONVOLUTION OF TWO SIGNALS PROGRAM 03: LINEAR CONVOLUTION OF TWO SIGNALS USING FFT & IFFT PROGRAM 04: AUTO CORRELATION OF A SEQUENCE PROGRAM 05: CROSS CORRELATION OF TWO SEQUENCES PROGRAM 06: N POINT DFT PROGRAM 07: IMPULSE RESPONSE OF A SYSTEM PROGRAM 08: DIFFERENCE EQUATION PROGRAM 09: BUTTERWORTH IIR FILTER PROGRAM 10: CHEBYSHEV IIR FILTER PROGRAM 11: FIR FILTER USING RECTANGULAR WINDOW PROGRAM 12: CIRCULAR CONVOLUTION OF TWO SIGNALS PROGRAM 13: CIRCULAR CONVOLUTION OF TWO SIGNALS USING FFT& IFFT PROGRAM 14: SAMPLING THEOREM 2 2 3 3 4 4 4 5 5 7 9 10 10 11

PART B: CODE COMPOSER STUDIO
PROGRAM 01: LINEAR CONVOLUTION OF TWO SIGNALS PROGRAM 02: CIRCULAR CONVOLUTION OF TWO SIGNALS PROGRAM 03: DIFFERENCE EQUATION PROGRAM 04: N POINT DFT PROGRAM 05: IMPULSE RESPONSE OF A SYSTEM 12 12 13 13 14

0

DIGITAL SIGNAL PROCESSING LABORATORY – 10MTL78 1 .

xlabel('TIME'). stem(u.y3).3. p=0. ylabel('AMPLITUDE'). f=0. title('FIRST SEQUENCE'). SINE a=5. title('RAMP SIGNAL'). RAMP x3=[0 1 2 3 4]. h=input('INPUT THE SECOND SEQUENCE'). step.s). stem(u2. plot(t. plot(n. grid on. grid on. subplot(2. subplot(2.3. plot(x1. subplot(2.1. ramp. subplot(2.2).3). xlabel('TIME').1). xlabel('TIME'). subplot(2. y1=[0 0 1 1 1].2.1).x). xlabel('TIME'). subplot(2. x=input('INPUT THE FIRST SEQUENCE').y). title('STEP SIGNAL'). a3=-pi. xlabel('TIME'). subplot(2. PROGRAM 02: LINEAR CONVOLUTION OF TWO SIGNALS Write a MATLAB program to perform linear convolution of two signals. grid on. grid on.3.2. n2=length(h). ylabel('AMPLITUDE').3. IMPULSE x=[-2 -1 0 1 2]. title('CONVOLOUTION'). ylabel('AMPLITUDE').3). plot(x3. y=[0 0 1 0 0]. xlabel('TIME'). n1=length(x). u1=0:n1-1. y=exp(a3*n). ylabel('AMPLITUDE'). xlabel('TIME'). ylabel('AMPLITUDE'). subplot(2. plot(n.4) grid on.5:20.5).3. plot(x. title('SINE SIGNAL'). ylabel('AMPLITUDE'). ylabel('AMPLITUDE').y1). 2 .2. n=[0:10].y).y1). y1=conv(x. s=a*sin(2*pi*f*t+p). STEP x1=[-2 -1 0 1 2].y). subplot(2. xlabel('TIME'). stem(u1.DIGITAL SIGNAL PROCESSING LABORATORY – 10MTL78 PART A PROGRAM 01: GENERATION OF BASIC SIGNALS Write a MATLAB program to generate the basic signals: impulse. sine and exponential.2). y=exp(a2*n). xlabel('TIME'). y3=[0 1 2 3 4]. u2=0:n2-1. ylabel('AMPLITUDE'). title('IMPULSE SIGNAL'). grid on. ylabel('AMPLITUDE'). title('SECOND SEQUENCE'). grid on.6). grid on. n=[0:10]. grid on.h). t=0:0. u=0:length(y1)-1.h). EXPONENTIAL a2=pi. title('EXPONENTIAL SIGNAL').3. title('EXPONENTIAL SIGNAL').

x). end 3 .1. xlabel('TIME'). r=xcorr(x.2). u1=0:n1-1. subplot(2. h=input('INPUT THE SECOND SEQUENCE'). stem(u2.^2) ci=ceil(length(r)/2).2.n).*x2 y1=ifft(y. ylabel('AMPLITUDE'). subplot(2. x2=fft(h.h). title('INPUT SEQUENCE'). subplot(2. stem(u1. else display('SYMMETRY PROPERTY NOT PROVED').2. u1=0:length(x)-1. ylabel('AMPLITUDE'). u=0:n-1.r). stem(u2. n1=length(x). x=input('INPUT THE A SEQUENCE').n). xlabel('TIME').y1). grid on.3).n). and to prove the energy and symmetry property.2). subplot(2.x). n=n1+n2-1. xlabel('TIME'). x=input('INPUT THE FIRST SEQUENCE').x) u2=0:length(r)-1. stem(u. title('SECOND SEQUENCE'). y=x1. e=sum(x. else display('ENERGY PROPERTY NOT PROVED'). xlabel('TIME').2. t1=ci. title('FIRST SEQUENCE'). PROGRAM 04: AUTO CORRELATION OF A SEQUENCE Write a MATLAB program to perform auto correlation of a sequence.1). grid on. ylabel('AMPLITUDE'). u2=0:n2-1.DIGITAL SIGNAL PROCESSING LABORATORY – 10MTL78 PROGRAM 03: LINEAR CONVOLUTION OF TWO SIGNALS USING FFT & IFFT Write a MATLAB program to perform linear convolution of two signals using FFT and IFFT.1. x1=fft(x. n2=length(h). grid on. subplot(2. title('CONVOLOUTION'). ylabel('AMPLITUDE'). xlabel('TIME'). stem(u1. ylabel('AMPLITUDE'). grid on. t2=ci. title('AUTO CORELATED SEQUENCE'). end.1). if(r(t1)==r(t2)) display('SYMMETRY PROPERTY PROVED'). grid on. if(r(ci)==e) display('ENERGY PROPERTY PROVED').

stem(n. grid on. n). b=[1. subplot(1. u2=0:length(h)-1. y=input('INPUT THE SECOND SEQUENCE'). xlabel('TIME'). r=xcorr(x. 4 . stem(n. ylabel(‘AMPLITUDE’). -1/3]. title('INPUT SEQUENCE').2. subplot(2.2. xlabel('TIME').2). title('OUTPUT SEQUENCE').m). grid on. title(‘IMPULSE RESPONSE’). 1/8]. grid on.r). stem(u1.1). title('PHASE'). grid on.2).DIGITAL SIGNAL PROCESSING LABORATORY – 10MTL78 PROGRAM 05: CROSS CORRELATION OF TWO SEQUENCES Write a MATLAB program to perform cross correlation of two sequences. title('FIRST SEQUENCE'). xlabel('TIME').n) subplot(1. ylabel('AMPLITUDE').2. N=length(x). xlabel(‘TIME’). xlabel('TIME'). N=input(‘ENTER NUMBER OF SAMPLES:’). stem(u2.2.2). h). stem(n. stem(u2. xlabel('TIME').2. u1=0:length(x)-1. ylabel('AMPLITUDE').1).1). grid on.y) u3=0:length(r)-1. subplot(2. p=angle(x) subplot(2. w=exp(-j*2*pi*k*n/N) x=w*x' subplot(2. grid on. u1=0:length(n)-1.3).2.y). subplot(2. stem(u3. ylabel('AMPLITUDE'). x=input('INPUT THE FIRST SEQUENCE').p).2. title(‘IMPULSE SIGNAL’). PROGRAM 07: IMPULSE RESPONSE OF A SYSTEM Write a MATLAB program to generate the impulse response of a system.x).3). xlabel(‘TIME’).2. u2=0:length(y)-1. ylabel('AMPLITUDE'). h=impz(b. k=n'. n=0:N-1. a=[1 -3/4. title('SECOND SEQUENCE'). m=abs(x) subplot(2. xlabel('TIME').x). x=input('INPUT A SEQUENCE').4). grid on. stem(u1. ylabel('AMPLITUDE'). PROGRAM 06: N POINT DFT Write a MATLAB program to find the N point DFT of the given sequence. xlabel('TIME'). ylabel('AMPLITUDE'). subplot(2. ylabel(‘AMPLITUDE’).2. title('CROSS CORELATED SEQUENCE').x).a. stem(n. title('MAGNITUDE'). ylabel('AMPLITUDE').

stem(n. ws=input('STOPBAND FREQUENCY=').0:0.a. grid on. xlabel('NORMAL FREQUENCY').-3/4.-1/3]. subplot(2. subplot(2.1).01:pi.10)]. xlabel('TIME').1. [h.wn).ones(1. xlabel('NORMAL FREQUENCY'). title('MAGNITUDE RESPONSE'). ylabel('AMPLITUDE'). ylabel('GAIN'). title('FIRST INPUT SEQUENCE').2). xlabel('TIME'). stem(n. n=0:19.1). a=[1. x2=[zeros(1. grid on. plot(om/pi. rs=input('STOPBAND ATTENUATION='). subplot(2. ylabel('AMPLITUDE'). xi=x1-x2. ylabel('AMPLITUDE').w2. stem(n. ylabel('GAIN'). ph=angle(h).5).xi).ones(1. title('DIFFERENCE OF INPUT SEQUENCES'). [b.om]=freqz(b. grid on.2. xlabel('TIME'). x1=[zeros(1. PROGRAM 9. subplot(2.h). wp=input('PASSBAND FREQUENCY='). plot(om/pi.a.x1). [n. n 5 .rs).1.2.rp.xi) subplot(2. h=filter(b. grid on.DIGITAL SIGNAL PROCESSING LABORATORY – 10MTL78 PROGRAM 08: DIFFERENCE EQUATION Write a MATLAB program to solve a difference equation.a]=butter(n. rp=input('PASSBAND ATTENUATION=').15)].1/8].2. subplot(2.2.x2). xlabel('TIME'). w1=2*wp/fs. plot(n. ylabel('AMPLITUDE'). grid on.ph). title('SECOND INPUT SEQUENCE'). grid on.A: BUTTERWORTH LOW PASS DIGITAL IIR FILTER Write a MATLAB program to implement Butterworth low pass digital IIR filter. b=[1.3).10). title('DIFFERENCE EQUATION').w). m=20*log10(abs(h)). title('FREQUENCY RESPONSE').m). w=0. w2=2*ws/fs.2).4).wn]=buttord(w1. fs=input('SAMPLING FREQUENCY=').

'high').1.ph).wn]=buttord(w1. plot(om/pi.1.C: BUTTERWORTH BAND PASS DIGITAL IIR FILTER Write a MATLAB program to implement Butterworth band pass digital IIR filter.74315]. subplot(2. ylabel('GAIN'). ws=input('STOPBAND FREQUENCY='). w=0.om]=freqz(b. n PROGRAM 9. title('MAGNITUDE RESPONSE').1. xlabel('NORMAL FREQUENCY'). xlabel('NORMAL FREQUENCY'). grid on. w2=2*ws/fs. fs=input('SAMPLING FREQUENCY='). ylabel('GAIN'). rs=input('STOPBAND ATTENUATION=').a]=butter(n. subplot(2. [n.w2.rp.rs). n 6 .rs).DIGITAL SIGNAL PROCESSING LABORATORY – 10MTL78 PROGRAM 9. rs=input('STOPBAND ATTENUATION=').m).w2.0:0.3 0.ph). m=20*log10(abs(h)). title('FREQUENCY RESPONSE'). plot(om/pi. ph=angle(h). [b. m=20*log10(abs(h)).wn).w). subplot(2. w1=2*wp/fs. grid on. w1=2*wp/fs.a.0:0. wn=[0.om]=freqz(b.rp.1. ws=input('STOPBAND FREQUENCY='). plot(om/pi. subplot(2. title('MAGNITUDE RESPONSE'). [h.m). rp=input('PASSBAND ATTENUATION='). grid on. wp=input('PASSBAND FREQUENCY='). plot(om/pi.1).B: BUTTERWORTH HIGH PASS DIGITAL IIR FILTER Write a MATLAB program to implement Butterworth high pass digital IIR filter. title('FREQUENCY RESPONSE'). [h. [b.2).a.01:pi. xlabel('NORMAL FREQUENCY').2).wn. grid on. ylabel('GAIN').1).01:pi. xlabel('NORMAL FREQUENCY'). [n. fs=input('SAMPLING FREQUENCY='). ph=angle(h). w2=2*ws/fs. wp=input('PASSBAND FREQUENCY=').wn]=buttord(w1.a]=butter(n. rp=input('PASSBAND ATTENUATION=').w). ylabel('GAIN'). w=0.

w).1.01:pi. ph=angle(h). xlabel('NORMAL FREQUENCY').A: CHEBYSHEV LOW PASS DIGITAL IIR FILTER Write a MATLAB program to implement Chebyshev low pass digital IIR filter. ws=input('STOPBAND FREQUENCY=').m). ws=input('STOPBAND FREQUENCY='). [b.rs. plot(om/pi.rs).wn. subplot(2. wn=[0. grid on.wn]=buttord(w1.74315].rp.DIGITAL SIGNAL PROCESSING LABORATORY – 10MTL78 PROGRAM 9. w=0.rs). ph=angle(h).1).2). ylabel('GAIN'). [n.ph). [h. grid on. grid on.a]=cheby1(n. title('MAGNITUDE RESPONSE').w).3 0. title('FREQUENCY RESPONSE').1.rp.01:pi. w1=2*wp/fs.w2. fs=input('SAMPLING FREQUENCY='). title('MAGNITUDE RESPONSE'). w=0.'stop'). ylabel('GAIN').1).2). w2=2*ws/fs. n 7 . xlabel('NORMAL FREQUENCY').a.wn). xlabel('NORMAL FREQUENCY'). m=20*log10(abs(h)). fs=input('SAMPLING FREQUENCY='). ylabel('GAIN').wn]=cheb1ord(w1. w1=2*wp/fs. w2=2*ws/fs.m). plot(om/pi. subplot(2. rp=input('PASSBAND ATTENUATION='). [b. m=20*log10(abs(h)).a. plot(om/pi. rs=input('STOPBAND ATTENUATION=').1. plot(om/pi. grid on. subplot(2. wp=input('PASSBAND FREQUENCY='). ylabel('GAIN').1.0:0. n PROGRAM 10.om]=freqz(b. wp=input('PASSBAND FREQUENCY=').om]=freqz(b. rp=input('PASSBAND ATTENUATION='). xlabel('NORMAL FREQUENCY').0:0. subplot(2. [n.ph). title('FREQUENCY RESPONSE').D: BUTTERWORTH BAND STOP DIGITAL IIR FILTER Write a MATLAB program to implement Butterworth band stop digital IIR filter. rs=input('STOPBAND ATTENUATION=').w2.a]=butter(n. [h.

ws=input('STOPBAND FREQUENCY='). w2=2*ws/fs. plot(om/pi.1. fs=input('SAMPLING FREQUENCY=').DIGITAL SIGNAL PROCESSING LABORATORY – 10MTL78 PROGRAM 10.a]=cheby1(n. [h. subplot(2.0:0. grid on.a. ylabel('GAIN'). grid on. wp=input('PASSBAND FREQUENCY='). plot(om/pi.1). subplot(2. [n.rs).rs. grid on.2). title('MAGNITUDE RESPONSE').m). w=0.01:pi.om]=freqz(b. n PROGRAM 10.m). [b. subplot(2. grid on. rs=input('STOPBAND ATTENUATION=').wn.ph). [h. rs=input('STOPBAND ATTENUATION='). m=20*log10(abs(h)).a. w=0.1). w2=2*ws/fs. [n.3 0. subplot(2.a]=cheby1(n.w).1. n 8 .ph).rs. xlabel('NORMAL FREQUENCY').01:pi.2).w2. wn=[0.74315].wn). fs=input('SAMPLING FREQUENCY='). wp=input('PASSBAND FREQUENCY=').rp. xlabel('NORMAL FREQUENCY'). rp=input('PASSBAND ATTENUATION='). ws=input('STOPBAND FREQUENCY='). [b. ph=angle(h).B: CHEBYSHEV HIGH PASS DIGITAL IIR FILTER Write a MATLAB program to implement Chebyshev high pass digital IIR filter.wn]=cheb1ord(w1. ylabel('GAIN'). w1=2*wp/fs. plot(om/pi. title('FREQUENCY RESPONSE'). ph=angle(h).1. title('FREQUENCY RESPONSE').'high'). ylabel('GAIN').1. ylabel('GAIN'). xlabel('NORMAL FREQUENCY').0:0. plot(om/pi.om]=freqz(b.w2. rp=input('PASSBAND ATTENUATION='). w1=2*wp/fs.rs). xlabel('NORMAL FREQUENCY'). title('MAGNITUDE RESPONSE').wn]=cheb1ord(w1.w). m=20*log10(abs(h)).rp.C: CHEBYSHEV BAND PASS DIGITAL IIR FILTER Write a MATLAB program to implement Chebyshev band pass digital IIR filter.

ylabel('GAIN'). xlabel('NORMAL FREQUENCY'). grid on. subplot(2. xlabel('NORMAL FREQUENCY').DIGITAL SIGNAL PROCESSING LABORATORY – 10MTL78 PROGRAM 10. grid on. n1=n+1. w2=2*ws/fs.wn.2.a]=cheby1(n. m=20*log10(abs(h)).01:pi. plot(o/pi. end y=boxcar(n1). rs=input('STOPBAND RIPPLE='). rs=input('STOPBAND ATTENUATION='). m=20*log10(abs(h)).256).wn]=cheb1ord(w1. w1=2*wp/fs. subplot(2. m=20*log10(abs(h)).1.3 0.m). title('BAND STOP FILTER'). %BAND PASS FILTER wn=[wp ws].1. xlabel('NORMAL FREQUENCY').2).1). xlabel('NORMAL FREQUENCY'). fs=input('STOPBAND FREQUENCY='). grid on. [h.y).4).2. plot(o/pi. ylabel('GAIN').y). num=-20*log10(sqrt(rp*rs))-13. m=20*log10(abs(h)). n=n-1.y). title('FREQUENCY RESPONSE'). title('LOW PASS FILTER'). grid on. ylabel('GAIN'). m=20*log10(abs(h)). ph=angle(h). b=fir1(n.w2.3).wn. fs=input('SAMPLING FREQUENCY=').m).m).256).1. den=14. %LOW PASS FILTER b=fir1(n. plot(om/pi. [h o]=freqz(b.y).'high'.rs.2. subplot(2. f=input('SAMPLING FREQUENCY='). plot(o/pi. [h o]=freqz(b. %HIGH PASS FILTER b=fir1(n. ylabel('GAIN').m).'stop').rp.74315]. ylabel('GAIN'). [b.om]=freqz(b. ws=2*fs/f.2)~=0). [h o]=freqz(b. wp=input('PASSBAND FREQUENCY='). plot(om/pi. b=fir1(n.wp.wp. title('HIGH PASS FILTER'). ylabel('GAIN'). n PROGRAM 11: FIR FILTER USING RECTANGULAR WINDOW Write a MATLAB program to implement FIR filter using rectangular window. plot(o/pi. wp=2*fp/f. title('BAND PASS FILTER').'stop'. grid on. n=ceil(num/den).ph). 9 .m). if(rem(n. [n. n1=n. subplot(2.256). title('MAGNITUDE RESPONSE'). xlabel('NORMAL FREQUENCY').2).0:0.1. w=0.D: CHEBYSHEV BAND STOP DIGITAL IIR FILTER Write a MATLAB program to implement Chebyshev band stop digital IIR filter. wn=[0. grid on.a.w). fp=input('PASSBAND FREQUENCY='). subplot(2.1.2. subplot(2.1).rs). rp=input('PASSBAND RIPPLE='). rp=input('PASSBAND ATTENUATION='). ws=input('STOPBAND FREQUENCY='). [h o]=freqz(b.1.6*(fs-fp)/f.256). %BAND STOP FILTER wn=[wp ws]. xlabel('NORMAL FREQUENCY').wn.

1).2). xlabel('TIME'). h2=[a. u3=0:length(y)-1.2.2.[0. grid on. title('CIRCULAR CONVOLOUTION'). ylabel('AMPLITUDE'). stem(u1. b=circshift(a. subplot(2. u3=0:length(y)-1.1]).1).[0. title('FIRST SEQUENCE'). xlabel('TIME'). ylabel('AMPLITUDE').1]). stem(u2. u2=0:length(h)-1. a=circshift(h1. subplot(2.*h. grid on.1]). a1=x'. c=circshift(b. d=circshift(c.y). u1=0:length(x)-1.[0.x). xlabel('TIME'). u2=0:length(h)-1.1]). ylabel('AMPLITUDE'). m=length(a1).c.x).b. xlabel('TIME'). stem(u1. grid on.1]). ylabel('AMPLITUDE'). y=ifft(Y) subplot(2. x=input('ENTER THE FIRST SEQUENCE:'). b=circshift(a.1]). a=circshift(h1. h1=fliplr(h). xlabel('TIME'). c=circshift(b. y=h2*a1 subplot(2. stem(u2.2.c.[0.b. title('FIRST SEQUENCE').1]). Y=x. stem(u3.N). n=length(h2).3). 10 .d].[0. title('CIRCULAR CONVOLOUTION'). h=input('ENTER THE SECOND SEQUENCE:'). subplot(2. u1=0:length(x)-1.1]). d=circshift(c. ylabel('AMPLITUDE'). grid on. grid on.h).2).3).[0. xlabel('TIME').2. a1=x'. N=max(m. grid on.[0.DIGITAL SIGNAL PROCESSING LABORATORY – 10MTL78 PROGRAM 12: CIRCULAR CONVOLUTION OF TWO SIGNALS Write a MATLAB program to perform circular convolution of two signals. ylabel('AMPLITUDE').d]. h2=[a. x=input('ENTER THE FIRST SEQUENCE:').2. subplot(2. h=input('ENTER THE SECOND SEQUENCE:'). x=fft(x.N). title('SECOND SEQUENCE'). h=fft(h. title('SECOND SEQUENCE').n). stem(u3.h). h1=fliplr(h).2.y).[0. PROGRAM 13: CIRCULAR CONVOLUTION OF TWO SIGNALS USING FFT& IFFT Write a MATLAB program to perform circular convolution of two signals using FFT & IFFT.

sr=interp1(ts. ts=0:1/fs:p*(1/f1). f1=50. ylabel('AMPLITUDE').1). a1=5.3.'cubic').DIGITAL SIGNAL PROCESSING – 10MTL78 PROGRAM 14: SAMPLING THEOREM Write a MATLAB program to implement sampling theorem. ylabel('AMPLITUDE'). subplot(2.2).3.6) plot(tn. subplot(2. t=0:0. xlabel('TIME'). title('RECONSTRUCTED WAVE'). xlabel('TIME'). title('SECOND SINE WAVE'). plot(t. plot(t. xlabel('TIME'). f2=50. ylabel('AMPLITUDE').3. a2=10.sr). subplot(2.3. p=4. ylabel('AMPLITUDE').f2)) 11 . s2=a2*sin(2*pi*f2*t). s1=a1*sin(2*pi*f1*t).sa). xlabel('TIME'). subplot(2.s2). xlabel('TIME'). tn=0:(0.s1).3. title('SUMMED SINE WAVE').000001:p*(1/f1).01/fs):p*(1/f1). n=p*(fs/max(f1. subplot(2.tn. stem(ts. ylabel('AMPLITUDE').4).sa. title('SAMPLED SINE WAVE'). sa=a1*sin(2*pi*f1*ts)+a2*sin(2* pi*f2*ts).3). title('FIRST SINE WAVE'). plot(t. fs=200.s). s=s1+s2.

DIGITAL SIGNAL PROCESSING – 10MTL78 PART B PROGRAM 01: LINEAR CONVOLUTION OF TWO SIGNALS Write a C program to perform linear convolution of two signals.h> #include<math. } getch().j.0.circnv[i]). } } clrscr(). #include<stdio.y[i]). for(i=0. } k=k-1.h> #include<math.i++) { printf("\n=>").&y[i]).4.h> #include<conio. printf("LINEAR CONVOLOUTION OUTPUT\n\n"). j<n.i>0. j++) { cirmat[i][j+1]=cirmat[i-1][j]. int y[10]. j=1. j++) cirmat[i][j]=h[j]. j++) { circnv[j]=0. j<n. for(i=n-1.i++) { printf("=>%d\n". int i.j++) { y[i]+=x[j]*h[i-j]. } getch().&n). } for(j=0. scanf("%d".0. int circnv[8].0.0. for(j=0. } printf("\nENTER THE ELEMENTS OF THE SECOND SEQUENCE\n"). k=n-1.0.4. } 12 .i<(m+n-1). j<n.i<n.h[8].h> #include<conio. for(i=0. for(i=0.0}.3.i--) { h[j]=y[i].0.0. printf("ENTER THE LENGTH OF THE FIRST & SECOND SEQUENCE\n\n"). int x[10]={1.&x[i]). } for(i=0.2.h> void main() { int m=4.i<1. #include<stdio. } h[0]=y[0]. i<n.0.0.3.h> void main() { int x[8]. } PROGRAM 02: CIRCULAR CONVOLUTION OF TWO SIGNALS Write a C program to perform circular convolution of two signals. j++.0. for(j=0.i++) { y[i]=0. int h[10]={1. i++) { printf("\n=>"). for(k=0. i++) { cirmat[i][0]=h[k]. int n=4. int i. } } printf("\nCIRCULAR CONVOLUTION OUTPUT:\n\n").k. int cirmat[8][8]. k<n. i<n. scanf("%d".i++) { printf("=>%d\n\n".y[8]. printf("\nENTER THE ELEMENTS OF THE FIRST SEQUENCE\n").i<n. for(i=0. for(i=0.j<=i.i<(m+n-1).n. scanf("%d".j. k++) { circnv[j]+=cirmat[j][k]*x[k].i++) for(j=0.2.0}. clrscr(). for(i=1.

h> void dft(short*x.0/3. } clrscr(). for(n=3.h> void main() { float y[32]={0.n<7. int n.sumIm.0.2. int sumRe.3. if(k>N) k=0.2.1.i++) { cs=cos(2*pi*(k)*i/N).out[0]). int N=4.h> #include<conio.4:"). for(j=0.4}.0. void dft(short*x.DIGITAL SIGNAL PROCESSING – 10MTL78 PROGRAM 03: DIFFERENCE EQUATION Write a MATLAB program to solve a difference equation.n++) { y[n]=(x[n]-(1.n++) { printf("\n\n=>%f". int real[4].0)*y[n-1](1.0. int out[2]={0. } getch().short k. } getch().2.1416. float pi=3.0)*x[n1]+(3. float cs=0.int*out). image[k]=sumIm.i<N.j.0}.sn=0.j++) { dft(x.short k.out). printf("\nDIFFERENCE EQUATION OUTUPTS OF 1. for(i=0. printf("\n\n%d". float x[32]={0. real[k]=sumRe. sumIm=sumIm-x[i]*sn.3. short x[4]={1. k++. } PROGRAM 04: N POINT DFT Write a C program to find the N point DFT of the given sequence. out[1]=sumIm.sumIm=0.0/4.4:").3. } OF 13 . sumRe=sumRe+x[i]*cs.3. sn=sin(2*pi*(k)*i/N).h> #include<conio.image[4]. #include<stdio. int j. for(n=3.0}.4}. #include<stdio.2. int i=0. } void main() { clrscr().0)*y[n-2]).int*out) { int sumRe=0.y[n]).0/8.j<N.n<7. } out[0]=sumRe.h> #include<math.k=0. printf("N-POINT DFT 1.

-0. float b[order+1]={1.DIGITAL SIGNAL PROCESSING – 10MTL78 PROGRAM 05: IMPULSE RESPONSE OF A SYSTEM Write a C program to find the impulse response of a system.j<len. #include<stdio. 0.k.h> #define order 2 #define len 10 float y[len]={0. void main() { clrscr().h> #include<conio.y[j]). } else { y[j]=-sum. int j. for(j=0. } 14 .j.3333}.0}. } getch(). } printf("\n\nIMPULSE RESPONSE [%d]=%f\n". } if(j<=order) { y[j]=b[j]-sum. for(k=1.0.j++) { sum=0.-0.k<=order.k++) { if((j-k)>=0) sum=sum+(a[k]*y[j-k]).sum.7500. float a[order+1]={1.1250}.