1. Verification of sampling theorem. 2. Impulse response of a given system. 3. Linear convolution of two given sequences. 4. Circular convolution of two given sequences. 5. utocorrelation of given sequence an! verification of its properties. ". Cross correlation of a given sequences an! verification of its properties. #. $olving a given !ifference equation. %. Computation of &'point ()* of a given sequence an! to plot magnitu!e an! phase spectrum. +. Linear convolution of two sequences using ()* an! I()*. 1,. Circular convolution of two sequences using ()* an! I()*. 11. (esign an! implementation of )I- filter to meet given specifications. 12. (esign an! implementation of II- filter to meet given specifications. PART-B. LIST OF EXPERIMENTS USING DSP PROCESSOR. 1. Linear convolution of two given sequences. 2. Circular convolution of two given sequences. 3. Computation of &'point ()* of a given sequence. 4. -eali.ation of an )I- filter /any type0 to meet given specifications. *he input can 1e a signal from function generator2speech signal. 5. u!io application such as to plot a time an! frequency !isplay of a 3icrophone plus a cosine using ($4. -ea! a .wav file an! match with their respective spectrograms. ". &oise removal5 !! noise a1ove 367. an! then remove8 interference suppression using 4,,7. tone. #. Impulse response of first or!er an! secon! or!er system. 1 2 EXPERIMENT NO-1 AIM: VERIFICATION OF SAMPLING THEOREM Samplin: Is the process of converting a continuous time signal into a !iscrete time signal. It is the first step in conversion from analog signal to !igital signal. Samplin !"#$%#m: $ampling theorem states that 9:;act reconstruction of a continuous time 1ase'1an! signal from its samples is possi1le8 if the signal is 1an!'limite! an! the sampling frequency is greater than twice the signal 1an!wi!th<. i.e. f s = 2>8 where > is the signal 1an!wi!th.
N&'(i)! Ra!# Samplin: *he &yquist rate is the minimum sampling rate require! to avoi! aliasing8 equal to the highest mo!ulating frequency containe! within the signal. In other wor!s8 &yquist rate is equal to two si!e! 1an!wi!th of the signal /?pper an! lower si!e1an!s0 *o avoi! aliasing8 the sampling rate must e;cee! the &yquist rate. i.e. f s = f & P%$%am: @ &yquist -ate $ampling. clcA @ Clear screen fs B 14,,A @ $ampling frequency8 fs B 14,,7. t B ,512fs5132fsA @ &um1er of samples ; B cos/2CpiC4,,Ct0Dcos/2CpiC#,,Ct0A @ Input signal ;m B a1s /fft/;00A @ (etermine the a1solute ))* of the input signal !isp/E;mF0A @ (isplays ;m on comman! win!ow !isp /;m0A @ (isplays values of ;m on comman! win!ow G B ,5length/;m0'1A @ &um1er of samples to 1e plot on ;'a;is su1plot /282810A @ (ivi!e the figure win!ow to plot the output stem /1,,CG8 ;m0A @ 4lot the output ;la1el /H7.H0A @ &ame ;'a;is as 97.< yla1el /H3agnitu!eH0A @ &ame y'a;is as 93agnitu!e< title /H&- samplingH0A @ *itle is 9&- $ampling< @?&(:- $ampling. fs B 1,,,A @ $ampling frequency8 fs B 1,,,7. t B ,512fs5+2fsA @ &um1er of samples ; B cos/2CpiC4,,Ct0Dcos/2CpiC#,,Ct0A @ Input signal ;m B a1s/fft/;00A @ (etermine the a1solute ))* of the input signal !isp/E;m1F0A @ (isplays ;m1 on comman! win!ow !isp /;m10A @ (isplays values of ;m1 on comman! win!ow G B ,5length/;m10'1A @ &um1er of samples to 1e plot on ;'a;is su1plot/282820A @ (ivi!e the figure win!ow to plot the output stem/1,,CG8 ;m10A @ 4lot the output ;la1el/H7.H0A @ &ame ;'a;is as 97.< 3 yla1el/H3agnitu!eH0A @ &ame y'a;is as 93agnitu!e< title/H?&(:- samplingH0A @ *itle is 9?&(:- $ampling< @IV:- $ampling. fs B 2,,,A @ $ampling frequency8 fs B 2,,,7. t B ,512fs52,2fsA @ &um1er of samples ; B cos/2CpiC4,,Ct0Dcos/2CpiC#,,Ct0A @ Input signal ;m B a1s/fft/;00A @ (etermine the a1solute ))* of the input signal !isp/E;m2F0A @ (isplays ;m2 on comman! win!ow !isp /;m20A @ (isplays values of ;m2 on comman! win!ow G B ,5length/;m20'1A @ &um1er of samples to 1e plot on ;'a;is su1plot/282830A @ (ivi!e the figure win!ow to plot the output stem/1,,CG8;m20A @ 4lot the output ;la1el/H7.H0A @ &ame ;'a;is as 97.< yla1el/H3agnitu!eH0A @ &ame y'a;is as 93agnitu!e< title/HIV:- samplingH0A @ *itle is 9IV:- $ampling< OUTPUT : ;m Columns 1 through # ,.,,,, ,.,,,, ,.,,,, ,.,,,, #.,,,, ,.,,,, ,.,,,, Columns % through 14 14.,,,, ,.,,,, ,.,,,, #.,,,, ,.,,,, ,.,,,, ,.,,,, ;m1 Columns 1 through # ,.,,,, ,.,,,, ,.,,,, 5.,,,, 5.,,,, ,.,,,, 5.,,,, Columns % through 1, 5.,,,, ,.,,,, ,.,,,, ;m2 Columns 1 through # 2.,,,, 2.,#41 2.34+" 3.1",# 11.512# ,.4,52 1.%++% Columns % through 14 %."1"5 4.2355 1.2552 ,.335# ,.335# 1.2552 4.2355 Columns 15 through 21 %."1"5 1.%++% ,.4,52 11.512# 3.1",# 2.34+" 2.,#41 4 0 500 1000 1500 0 5 10 15 Hz M a g n i t u d e NR sampling 0 500 1000 0 2 4 6 Hz M a g n i t u d e UNDER sampling 0 500 1000 1500 2000 0 5 10 15 Hz M a g n i t u d e OVER sampling
5 EXPERIMENT NO-* AIM: IMPULSE RESPONSE OF A GIVEN S+STEM !iscrete time system performs an operation on an input signal 1ase! on a pre!efine! criteria to pro!uce a mo!ifie! output signal. *he input signal ;/n0 is the system e;citation8 an! y/n0 is the system response. *he transform operation is shown as8
;/n0 y/n0 B *J/;/n0K If the input to the system is unit impulse i.e. ;/n0 B L/n0 then the output of the system is Gnown as impulse response !enote! 1y h/n0 where8 h/n0 B *JL/n0K we Gnow that any ar1itrary sequence ;/n0 can 1e represente! as a weighte! sum of !iscrete impulses. &ow the system response is given 1y8 M y/n0 B *J;/n0K B *JN;/G0 L/n'G0K O/10 GB'M )or linear system /10 re!uces to M y/n0 B N;/G0 *JL/n'G0K O/20 GB'M *he response to the shifte! impulse sequence can 1e !enote! 1y h/n8 G0 is !enote! 1y8 h/n8 G0 B *JL/n'G0K O/30 )or a time'invariant system h/n8 G0 B h/n'G0 O/40 ?sing /40 in /30 we o1tain8 *JL/n'G0K B h/n'G0 O/50 ?sing /50 in /20 we get8 M y/n0 B N;/G0 h/n'G0 O/"0 GB'M 6
* )or a linear time'invariant system if the input sequence is ;/n0 an! impulse response h/n0 is given8 we can fine output y/n0 1y using eqn /"0. >hich is Gnown as convolution sum an! can 1e represente! 1y y/n0 B ;/n0 C h/n0 F$% E,ampl# l#!-) .in/ $(! an imp(l)# %#)p$n)# $. a /i..#%#n0# #'(a!i$n. *he general form of !ifference equation is8 3 3 y/n0 B Na G y/n'G0 D N1 G ;/n'G0 O/#0 GB1 GB, )or input ;/n0 B L/n0 3 y/n0 B N1 G ;/n'G0 B , for n = 3 GB, &ow /#0 can 1e written as8 & y/n0 B Na G y/n'G0 B , a , B 1 O/%0 GB, *he solution of eqn /%0 is Gnown as homogeneous solution. *he particular solution is .ero since ;/n0 B , for n = ,8 that is y p /n0 B , *herefore we can o1tain the impulse response 1y solving the homogeneous equation an! imposing the initial con!itions to !etermine the ar1itrary constants. E,ampl#: LetFs taGe a secon! or!er !ifference equation y/n0 P /12"0 y/n'10 P/12"0 y/n'20 B ;/n0 O/+0 )or impulse response the particular solution y p /n0 B , $o8 y/n0 B y h /n0 O/1,0 Let y h /n0 B Q n O/110 $u1stituting /110 in /+0 we get8 Q n ' /12"0 Q n'1 P /12"0 Q n'2 B , / ;/n0 B , for homogeneous solution0 or Q 2 ' /12"0 Q P /12"0 B , O/120 7 *he roots of the characteristic equation are8 Q 1 B 1228 Q 2 B '123 *he solution y h /n0 B C 1 /1220 n D C 2 /'1230 n O/130 )or impulse ;/n0 B L/n0A ;/n0 B , for n = , an! ;/,0 B 1 $u1stituting the a1ove relations in eqn /+0 we have8 )or n B ,8 y/,0 P /12"0 y/'10 P/12"0 y/'20 B ;/,0 B 1 i.e. y/,0 B 1. O/140 )or n B 18 y/10 P /12"0 y/,0 P/12"0 y/'10 B ;/10 y/10 P /12"0 B , y/10 B 12". O/150 )rom eqn /130 y/,0 B C 1 D C 2 O/1"0 y/10 B /1220C 1 P /1230C 2 O/1#0 Comparing equations /1408 /1508 /1"0 an! /1#0 we get8 C 1 D C 2 B 1 /1220C 1 P /1230C 2 B /12"0 $olving for C 1 an! C 2 we get8 C 1 B 3258 C 2 B 225 *herefore8 the solution y/n0 B /3250/1220 n D /2250/'1230 n O/1%0 &ow8 letFs fin! out impulse response. >e Gnow that8 y/n0 B ;/n0 C h/n0 h/n0 B y/n0 2 ;/n0 O/1+0 8 Compute y/n0 for various values of n $u1stitute n B ,8 18 28 3 in eqn /1%0 we get8 y/,0 B 1.,,,, y/10 B ,.1""# y/20 B ,.1+44 y/30 B ,.,",2 $o8 y/n0 B R1.,,,,8 ,.1""#8 ,.1+448 ,.,",2S >e Gnow that8 ;/n0 B 1 $o8 the impulse response for the given !ifference equation using eqn /1+0 is h/n0 B R1.,,,,8 ,.1""#8 ,.1+448 ,.,",2S P%$%am: clcA @ Clear screen nr B J1KA @ &umeartor co'efficients !r B J18'12"8'12"KA @ (enominator co'efficients h B imp./nr8!r840A @ Computes the impulse response of a given @ !ifference equation8 returns the co'efficients !isp/HImpulse response h/n05H0A@ (isplays impulse response !isp/h0A @ (isplays impulse response on comman! win!ow su1plot/281810A @ (ivi!e the figure win!ow to plot the output stem/h0A @ (isplays the impulse response title/HImpulse response h/n05H0A@ *itle as impulse response ; B J1KA @ Input co'efficients y B conv /h8 ;0A @ Convolution of input an! impulse co'efficients to get the @ output !isp/HIutput y/n05H0 @ (isplays Iutput y/n0 !isp/y0A @ (isplays the output on comman! win!ow su1plot/281820A @ (ivi!e the figure win!ow to plot the output stem/y0A @ 4lots the output title/HIutput y/n0 for given ;/n0H0A @ *itle as 9Iutput y/n0 for given ;/n0< OUTPUT: Impulse response5 1.,,,, ,.1""# ,.1+44 ,.,",2 Iutput y/n05 1.,,,, ,.1""# ,.1+44 ,.,",2 9 1 1.5 2 2.5 3 3.5 4 0 0.5 1 Impulse response 1 1.5 2 2.5 3 3.5 4 0 0.5 1 Output y(n) for given x(n) 10 EXPERIMENT NO-1 AIM: TO IMPLEMENT LINEAR CONVOLUTION OF T2O GIVEN SE3UENCES T"#$%&: Convolution is an integral concatenation of two signals. It has many applications in numerous areas of signal processing. *he most popular application is the !etermination of the output signal of a linear time'invariant system 1y convolving the input signal with the impulse response of the system. &ote that convolving two signals is equivalent to multiplying the )ourier *ransform of the two signals. Ma!"#ma!i0 F$%m(la: *he linear convolution of two continuous time signals ;/t0 an! h/t0 is !efine! 1y )or !iscrete time signals ;/n0 an! h/n08 is !efine! 1y >here ;/n0 is the input signal an! h/n0 is the impulse response of the system. In linear convolution length of output sequence is8 length/y/n00 B length/;/n00 D length/h/n00 P 1 G%ap"i0al In!#%p%#!a!i$n: -eflection of h/G0 resulting in h/'G0 $hifting of h/'G0 resulting in h/n'G0 :lement wise multiplication of the sequences ;/G0 an! h/n'G0 $ummation of the pro!uct sequence ;/G0 h/n'G0 resulting in the convolution value for y/n0 E,ampl#: ;/n0 B R18 28 38 1S h/n0 B R18 18 1S length/y/n00 B length/;/n00 D length/y/n00 P 1 B 4 D 3 P 1 B " 11 ;/G0 h/G0 3 2 1 1 1 1 1 '4 '3 '2 '1 , 1 2 3 4 5 " # , 1 2 M nB,A h/'G 0 y/,0 B N ;/G0 h/'G0 B 1 1 GB'M '4 '3 '2 '1 , 1 2 3 4 5 " # M nB1A h/1'G0 y/10 B N ;/G0 h/1'G0 B 1D2B3 1 GB' M
'4 '3 '2 '1 , 1 2 3 4 5 " # M nB4A h/4'G0 y/40 B N ;/G0 h/4'G0 B 3D1B4 1 GB'M '4 '3 '2 '1 , 1 2 3 4 5 " # M nB5A h/5'G0 y/50 B N ;/G0 h/5'G0 B 1 1 GB'M '4 '3 '2 '1 , 1 2 3 4 5 " # 12 " "
4 3 y/n0 B R18 38 "8 "8 48 1S 1 1 '4 '3 '2 '1 , 1 2 3 4 5 " # P%$%am: clcA @ Clear screen ;1 B input/H:nter the 1st seq5H0A @ Tet the first sequence ;2 B input/H:nter the 2n! seq5H0A @ Tet the secon! sequence y B conv/;18 ;20A @ Convolve two signals !isp/H*he linear convolution of two sequences5H0A @ (isplays the result !isp/y0A @ (isplays the result on comman! win!ow n B ,5length/y0'1A @ (efines the length for ;'a;is stem/n8 y0A @ 4lots the output ;la1el/H*imeH0A @ &ame the ;'a;is as *ime yla1el/H3agnitu!eH0A @ &ame the y'a;is as 3agnitu!e title/HLinear convolutionH0A @ *itle as 9Linear convolution< OUTPUT: :nter the 1st seq5J1 2 3 1K :nter the 2n! seq5J1 1 1K *he linear convolution of two sequences5 1 3 " " 4 1 13 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 0 1 2 3 4 5 6 Time M a g n i t u d e Linear convolution
14 EXPERIMENT NO-4 AIM: TO IMPLEMENT CIRCULAR CONVOLUTION OF T2O GIVEN SE3UENCES Ci%0(la% 0$n5$l(!i$n: Let ; 1 /n0 an! ; 2 /n0 are finite !uration sequences 1oth of length & with ()*Fs U 1 /G0 an! U 2 /G0. Convolution of two given sequences ; 1 /n0 an! ; 2 /n0 is given 1y the equation8 ; 3 /n0 B I()*JU 3 /G0K U 3 /G0 B U 1 /G0 U 2 /G0 &'1 ; 3 /n0 B N ; 1 /m0 ; 2 //n'm00 & mB, E,ampl#: LetFs taGe ; 1 /n0 B R18 18 28 1S an! ; 2 /n0 B R18 28 38 4S rrange ; 1 /n0 an! ; 2 /n0 in circular fashion as shown 1elow. ; 1 /m0 ; 2 /m0 1 2 ; 1 /10 ; 2 /10
; 2 /10 2 ; 3 /,0 B ; 1 /m0 ; 2 /'m0 B ; 1 /,0 ; 2 /,0 D ; 1 /10 ; 2 /30 D ; 1 /20 ; 2 /20 D ; 1 /30 ; 2 /10 B 1 D 4 D " D2 ; 3 /,0 B 13 6eep ; 1 /m0 constant an! rotate ; 2 /'m0 once to compute further values. *o get ; 3 /10 rotate ; 2 /'m0 1y one sample in anti'clocGwise !irection
; 2 /1'm0 1 ; 2 /,0 ; 2 /30 ; 2 /10 4 2
; 2 /20 3 ; 3 /10 B ; 1 /m0 ; 2 /1'm0 B ; 1 /,0 ; 2 /10 D ; 1 /10 ; 2 /,0 D ; 1 /20 ; 2 /30 D ; 1 /30 ; 2 /20 B 2 D 1 D % D 3 16 ; 3 /10 B 14 *o get ; 3 /20 rotate ; 2 /1'm0 1y one sample in anti'clocGwise !irection ; 2 /2'm0 2 ; 2 /10 1 3 ; 2 /,0 ; 2 /20 ; 2 /30 4 ; 3 /20 B ; 1 /m0 ; 2 /2'm0 B ; 1 /,0 ; 2 /20 D ; 1 /10 ; 2 /10 D ; 1 /20 ; 2 /,0 D ; 1 /30 ; 2 /30 B 3 D 2 D 2D 4 ; 3 /20 B 11 *o get ; 3 /30 rotate ; 2 /2'm0 1y one sample in anti'clocGwise !irection ; 2 /3'm0 3 ; 2 /20 2 4 ; 2 /10 ; 2 /30
; 2 /,0 1 ; 3 /30 B ; 1 /m0 ; 2 /3'm0 B ; 1 /,0 ; 2 /30 D ; 1 /10 ; 2 /20 D ; 1 /20 ; 2 /10 D ; 1 /30 ; 2 /,0 B 4 D 3 D 4 D 1 ; 3 /30 B 12 *he convolute! signal is8 17 ; 3 /n0 B R138 148 118 12S P%$%am: clcA @ Clear screen ;1 B input/H:nter 1st seq5H0A @ Tet the first sequence ;2 B input/H:nter 2n! seq5H0A @ Tet the secon! sequence n B ma;/length/;108length/;200A @ Tet the 3a;imum length out of two signals ;1 B fft/;18n0A @ Compute ))* of the first sequence ;2 B fft/;28n0A @ Compute ))* of the secon! sequence y B ;1.C;2A @ 3ultiply the two sequences yc B ifft/y8n0A @ Compute I))* of the result !isp/Hcircular convolution5H0A @ (isplays circular convolution !isp/yc0A @ (isplays the result on comman! win!ow &B,515n'1A @ Tet the length for ;'a;is su1plot/181810A @ (ivi!e the win!ow to plot the result stem/&8yc0A @ 4lot the result ;la1el/H*imeH0A @ &ame the ;'a;is as 9*ime< yla1el/H3agnitu!eH0A @ &ame the y'a;is as 93agnitu!e< title/HCircular convolutionH0A @ *itle as Circular convolution OUTPUT: :nter 1st seq5J1 1 2 1K :nter 2n! seq5J1 2 3 4K Circular convolution5 13 14 11 12 18 0 0.5 1 1.5 2 2.5 3 0 5 10 15 Time M a g n i t u d e Circular convolution EXPERIMENT NO-6 AIM: AUTOCORRELATION OF A GIVEN SE3UENCE AND VERIFICATION OF ITS PROPERTIES C$%%#la!i$n: Correlation !etermines the !egree of similarity 1etween two signals. If the signals are i!entical8 then the correlation coefficient is 1A if they are totally !ifferent8 the correlation coefficient is ,8 an! if they are i!entical e;cept that the phase is shifte! 1y e;actly 1%, , /i.e. mirrore!08 then the correlation coefficient is '1. A(!$0$%%#la!i$n: >hen the same signal is compare! to phase shifte! copies of itself8 the proce!ure is Gnown as autocorrelation. *he autocorrelation of a ran!om signal !escri1es the general !epen!ence of the values of the samples at one time on the values of the samples at another time. Consi!er a ran!om process ;/t0 /i.e. continuous time08 its autocorrelation function is8 19 >here * is the perio! of o1servation. - xx /V0 is always real value! an! an even function with a ma;imum value at V B ,. )or sample! signal8 the autocorrelation function is !efine! as8 Wiase! autocorrelation O.. :qn.1 ?n1iase! autocorrelation )or m B 1 D 2 D O. D 3D1 >here 3 is the num1er of lags. E,ampl#: A(!$0$%%#la!i$n $. a )in# 7a5#. 4lot the autocorrelation of a sine wave with frequency of 1 7.8 sampling frequency of 2,, 7.. &ote that we use! the function ;corr to estimate the autocorrelation sequence8 it has !ou1le the num1er of samples as the signal ;/n0. n important point to remem1er when using the function ;corr is that the origin is in the mi!!le of the figure /here it is at lag B 1,240. ;corr is a 1uilt in function in 3*LW li1rary. P%$%am: clcA @ Clear screen & B 1,24A @ &um1er of samples f1 B 1A @ )requency of the sine wave )s B 2,,A @ $ampling frequency n B ,5 &'1A @ $ample in!e; num1ers ; B sin/2CpiCf1Cn2)s0A @ Input sine wave ;/n0 t B J15&KC/12)s0A @ (efines the length for ;'a;is su1plot/281810A @ (ivi!e the figure win!ow to plot the result 20 plot/t8 ;0A @ 4lot the sine wave on the figure win!ow title/H$ine wave of frequency 1 7. /)s B 2,, 7.0H0A @ *itle ;la1el/H*imeH0A @ &ame ;'a;is as 9*ime< yla1el/Hmplitu!eH0A @ &ame y'a;is as 9mplitu!e< -;; B ;corr/;0A @ :stimate its autocorrelation using the function ;corr su1plot/281820A @ (ivi!e the figure win!ow plot/-;;0A @ 4lot the autocorrealate! signal on figure win!ow title/Hutocorrelation function of the sine waveH0A @ *itle ;la1el/HlagsH0A @ &ame ;'a;is as 9lags< yla1el/HutocorrelationH0A @ &ame y'a;is 9utocorrelation< OUTPUT: 21 0 1 2 3 4 5 6 -1 -0.5 0 0.5 1 Sinewave of frequency 1 Hz (Fs = 200 Hz) Time, [s] A m p l i t u d e 0 500 1000 1500 2000 2500 -500 0 500 1000 Autocorrelation function of the sine wave lags A u t o c o r r e l a t i o n >e can also inclu!e our own functions to the MATLAB li1rary 1y saving the file name with .m e;tension. )or #,ampl# we can write the autocorrelation function for the sample! signal !efine! in :qn.18 an! we shoul! save this file as autom.m function J-;;K B autom/;0 & B length/;0A -;; B .eros/18&0A for m B 15 &D1 for n B 15 &'mD1 -;;/m0 B -;;/m0 D ;/n0C;/nDm'10A en!A en!A >e can call this function autom in the main program instea! of the function ;corr8 we will get the output as8 OUTPUT: 22 0 1 2 3 4 5 6 -1 -0.5 0 0.5 1 Sinewave of frequency 1 Hz (Fs = 200 Hz) Time, [s] A m p l i t u d e 0 200 400 600 800 1000 1200 -500 0 500 1000 Autocorrelation function of the sine wave lags A u t o c o r r e l a t i o n
EXPERIMENT NO-8 23 AIM: CROSS-CORRELATION OF A GIVEN SE3UENCE AND VERIFICATION OF ITS PROPERTIES C$%%#la!i$n: Correlation !etermines the !egree of similarity 1etween two signals. If the signals are i!entical8 then the correlation coefficient is 1A if they are totally !ifferent8 the correlation coefficient is ,8 an! if they are i!entical e;cept that the phase is shifte! 1y e;actly 1%, , /i.e. mirrore!08 then the correlation coefficient is '1. C%$))-0$%%#la!i$n: >hen two in!epen!ent signals are compare!8 the proce!ure is Gnown as cross-correlation. *he cross correlation function measures the !epen!ence of the value of one signal on another signal. )or two >$$ />i!e $ense $tationary0 processes ;/t0 an! y/t0 it is !escri1e! 1y8 Ir >here * is the o1servation time. )or sample! signals8 cross'correlation is !efine! as8 )or m B 1 D 2 D O.. D &D1 >here & is the recor! length /i.e. num1er of samples0. E,ampl#: 4lot the cross correlation for the following signal8 24 ;/n0 B sin/2Xf 1 t0 with f 1 B 1 7. y/n0 B ;/n0 D w/n0 >here w/n0 is a .eroes mean8 unit variance of Taussian ran!om process. P%$%am: clcA @ Clear screen & B 1,24A @ &um1er of samples f1 B 1A @ )requency of the sine wave )s B 2,,A @ $ampling frequency n B ,5 &'1A @ $ample in!e; num1ers ; B sin/2CpiCf1Cn2)s0A @ Input sine wave ;/n0 y B ; D 1,Cran!n/18 &0A @ !! noise to the input signal t B J15&KC/12)s0A @ (efines the length for ;'a;is su1plot/381810A @ (ivi!e the figure win!ow to plot the result plot/;0A @ 4lot the sine wave title/E4ure sine waveH0A @ *itle as 94ure sine wave< ;la1el/H*imeH0A @ &ame ;'a;is as 9*ime< yla1el/Hmplitu!eH0A @ &ame y'a;is as 9mplitu!e< su1plot/381820A @ (ivi!e the figure win!ow to plot the result plot/y0A @ 4lot the sine wave with noise title/E4ure sine wave D &oiseH0A @ *itle as 94ure sine wave D &oise< ;la1el/H*imeH0A @ &ame ;'a;is as 9*ime< yla1el/Hmplitu!eH0A @ &ame y'a;is as 9mplitu!e< -;y B ;corr/;8y0A @ :stimate its cross'correlation using the function ;corr su1plot/381830A @ (ivi!e the figure win!ow to plot the result plot/-;y0A @ 4lot the cross'correlate! signal on figure win!ow title/HCross'correlation -;yF0A @ *itle as 9Cross'correlation -;y< ;la1el/HlagsH0A @ &ame ;'a;is as 9lags< yla1el/HCross'correlationH0A @ &ame y'a;is 9Cross'correlation< OUTPUT: 25 0 200 400 600 800 1000 1200 -1 0 1 Pure sine wave Time A m p l i t u d e 0 200 400 600 800 1000 1200 -50 0 50 Pure sine wave + Noise Time A m p l i t u d e 0 500 1000 1500 2000 2500 -1000 0 1000 Cross-correlation Rxy lags C r o s s - c o r r e l a t i o n EXPERIMENT NO-9 26 AIM: TO SOLVE A GIVEN DIFFERENCE E3UATION Teneral & th or!er (ifference equations looGs liGe8 yJnK D a 1 yJn'1K D a 2 yJn'2K D OD a & yJn'&0 B 1 , ;JnK D 1 1 ;Jn'1K D O. D 1 3 ;Jn'3K 7ere yJnK is 93ost a!vance!< output sample an! yJn'mK is 9Least a!vance!< ouput sample. *he !ifference 1etween these two in!e; values is the or!er of the !ifference equation. 7ere we have5 n'/n'&0 B & >e can rewrite the a1ove equation as8 yJnK D Na i yJn'iK B N1 i ;Jn'iK yJnK 1ecomes8 yJnK B 'Na i yJn'iK D N1 i ;Jn'iK E,ampl#: yJnD2K P 1.5yJnD1K D yJnK B 2;JnK In general we start with the 93ost a!vance!< output sample. 7ere it is yJnD2K. $o8 here we nee! to su1tract 2 from each sample argument. >e get yJnK P 1.5yJn'1K D yJn'2K B 2;Jn'2K yJnK B 1.5yJn'1K ' yJn'2K D 2;Jn'2K Lets assume our input ;JnK B uJnK B , ;Y, 1 ;Z, In our e;ample we have taGen ;JnK B uJnK B , ;Y, 1 ,[;Y1, >e nee! & past values to solve & th or!er !ifference equation. yJ'2K B 1 yJ'1K B 2 Compute yJnK for various values of n 27 yJ,K B 1.5yJ'1K ' yJ'2K D 2;J'2K B 1.5C2 P 1 D 2C, yJ,K B 2 yJ1K B 1.5yJ,K ' yJ'1K D 2;J'1K B 1.5C2 ' 2 D 2C, yJ1K B 1 yJ2K B 1.5yJ1K ' yJ,K D 2;J,K B 1.5C1 P 2 D 2C1 yJ2K B 1.5 n! so onO P%$%am: clcA @ Clear screen ; B J, , ones/18 1,0KA @ Input ;JnK B uJnK y\past B J1 2KA @ 4ast values to solve !ifference equation y/10 B y\past/10A @ yJ1K YB yJ'2K y/20 B y\past/20A @ yJ2K YB yJ'1K
for G B 35/length/;0D20 @ Compute yJnK for various values of n y/G0 B 1.5Cy/G'10 ' y/G'20 D 2C;/G'20A en! @ :n! of for loop !isp/E$olution for the given !ifference equation5F0A !isp/y0A @ (isplay the result on comman! win!ow su1plot/181810A @ (ivi!e the win!ow to plot the result stem /'25/length/y0'308y0A @ 4lot the result ;la1el/EInput ;JnKF0A @ &ame ;'a;is as Input ;JnK yla1el/EIutput yJnKF0A @ &ame y'a;is as Iutput yJnK title/E(ifference equationF0A @ *itle as 9(ifference equation< OUTPUT: $olution for the given !ifference equation5 Columns 1 through # 1.,,,, 2.,,,, 2.,,,, 1.,,,, 1.5,,, 3.25,, 5.3#5,
Columns % through 14 ".%125 ".%43% 5.4531 3.335+ 1.55,% ,.++,2 1.+34" 28 -2 0 2 4 6 8 10 12 0 2 4 6 8 Input x[n] O u t p u t
y [ n ] Diference equation 29 EXPERIMENT NO-: AIM: TO COMPUTE N-POINT DFT OF A GIVEN SE3UENCE AND TO PLOT MAGNITUDE AND PHASE SPECTRUM. Di)0%#!# F$(%i#% T%an).$%m: *he (iscrete )ourier *ransform is a powerful computation tool which allows us to evaluate the )ourier *ransform U/e ]^ 0 on a !igital computer or specially !esigne! !igital har!ware. $ince U/e ]^ 0 is continuous an! perio!ic8 the ()* is o1taine! 1y sampling one perio! of the )ourier *ransform at a finite num1er of frequency points. part from !etermining the frequency content of a signal8 ()* is use! to perform linear filtering operations in the frequency !omain. *he sequence of N comple; num1ers x , 8...8 x N_1 is transforme! into the sequence of N comple; num1ers X , 8 ...8 X N_1 1y the ()* accor!ing to the formula5 &'1 U/G0 B N;/n0e ']2XnG2& G B ,818 O. &'1 nB, E,ampl#: Lets assume the input sequence ;JnK B J1 1 , ,K >e have8 &'1 U/G0 B N;/n0e ']2XnG2& G B ,818 O. &'1 nB, )or G B ,8 3 U/,0 B N;/n0 B ;/,0 D ;/10 D ;/20 D ;/30 nB, U/,0 B 1D1D,D, B 2 )or G B 18 3 U/10 B N;/n0e ']Xn22 B ;/,0 D ;/10 e ']X22 D ;/20 e ']X D ;/30 e ']3X22 nB, B 1 D cos/X220 ' ]sin/X220 U/10 B 1 P ] 30 )or G B 28 3 U/20 B N;/n0e ']Xn B ;/,0 D ;/10 e ']X D ;/20 e ']2X D ;/30 e ']3X nB, B 1 D cos X P ]sin X U/20 B 1'1 B , )or G B 38 3 U/30 B N;/n0e ']3nX22 B ;/,0 D ;/10 e ']3X22 D ;/20 e ']3X D ;/30 e ']+X22 nB, B 1 D cos/3X220 ' ]sin/3X220 U/30 B 1 D ] *he ()* of the given sequence is8 U/G0 B R 28 1']8 ,8 1D] S P%$%am: clcA @ Clear screen ;1 B input/H:nter the sequence5H0A @ Tet the input sequence n B input/H:nter the length5H0A @ Tet the value of & m B fft/;18n0A @ Computes the ()* using ))* algorithm !isp/H&'point ()* of a given sequence5H0A @ (isplay the results !isp/m0A @ (isplays the result on comman! win!ow & B ,515n'1A @ (eci!es the length to plot the results su1plot/282810A @ (ivi!e the figure win!ow to plot the @ results stem/&8m0A @ 4lots the magnitu!e spectrum ;la1el/HLengthH0A @ &ame ;'a;is as 9Length< yla1el/H3agnitu!e of U/G0H0A @ &ame y'a;is as 93agnitu!e of U/G0< title/H3agnitu!e spectrum5H0A @ *itle as 93agnitu!e spectrum< an B angle/m0A @ Tet the angle of the output sequence U/G0 su1plot/282820A @ (ivi!e the figure win!ow to plot the @ results stem/&8 an0A @ 4lots the phase spectrum ;la1el/HLengthH0A @ &ame ;'a;is as 9Length< yla1el/H4hase of U/G0H0A @ &ame y'a;is as 94hase of U/G0< title/H4hase spectrum5H0A @ *itle as 94hase spectrum< 31 OUTPUT: :nter the sequence5 J1 1 , ,K :nter the length5 4 &'point ()* of a given sequence5 Columns 1 through 3 2.,,,, 1.,,,, ' 1.,,,,i , Column 4 1.,,,, D 1.,,,,i 0 1 2 3 0 0.5 1 1.5 2 Length M a g n i t u d e
o f
X ( k ) Magnitude spectrum: 0 1 2 3 -1 -0.5 0 0.5 1 Length P h a s e
o f
X ( k ) Phase spectrum: 32 EXPERIMENT NO-; AIM: LINEAR CONVOLUTION OF T2O GIVEN SE3UENCES USING DFT AND IDFT T"#$%&: Convolution is an integral concatenation of two signals. It has many applications in numerous areas of signal processing. *he most popular application is the !etermination of the output signal of a linear time'invariant system 1y convolving the input signal with the impulse response of the system. &ote that convolving two signals is equivalent to multiplying the )ourier *ransform of the two signals. Ma!"#ma!i0 F$%m(la: *he linear convolution of two continuous time signals ;/t0 an! h/t0 is !efine! 1y )or !iscrete time signals ;/n0 an! h/n08 is !efine! 1y >here ;/n0 is the input signal an! "<n= is the impulse response of the system. E,ampl#: ; 1 /n0 B R18 18 2S ; 2 /n0 B R18 2S )or linear convolution8 Length & B Length/; 1 0 D Length/; 2 0 ' 1 & B 3 D 2 P 1 B 4 Convolution of two sequences ; 1 /n0 an! ; 2 /n0 is8 ; 3 /n0 B I()*JU 3 /G0K ; 3 /n0 B I()*JU 1 /G0 U 2 /G0K >here8 U 1 /G0 B ()* J; 1 /n0K U 2 /G0 B ()* J; 2 /n0K 33 &'1 U 1 /G0 B N ; 1 /n0e ']2XGn2& GB ,8 18 28 O 8 &'1 nB, Tiven ; 1 /n0 B R18 18 2S an! &B4
3 U 1 /,0 B N ; 1 /n0 B 1 D 1 D 2 B 4 nB, 5 U 1 /10 B N ; 1 /n0e ']Xn22 B 1 P ] P 2 B '1 ' ] nB, 5 U 1 /20 B N ; 1 /n0e ']Xn B 1 P 1 D 2 B 2 nB, 5 U 1 /30 B N ; 1 /n0e ']3Xn22 B 1 D ] P 2 B '1 D ] nB, U 1 /G0 B R48 '1']8 28 '1D]S &ow8 &'1 U 2 /G0 B N ; 2 /n0e ']2XGn2& GB ,8 18 28 O 8 &'1 nB, Tiven ; 2 /n0 B R18 2S an! &B4 3 U 2 /,0 B N ; 2 /n0 B 1 D 2 B 3 nB,
34 3 U 2 /10 B N ; 2 /n0 e ']Xn22 B 1 D 2/']0 B 1 ' ]2 nB, 3 U 2 /20 B N ; 2 /n0 e ']Xn B 1 D 2/'10 B '1 nB, 3 U 2 /30 B N ; 2 /n0 e ']3Xn22 B 1 D 2/]0 B 1 D ]2 nB, U 2 /G0 B R38 1']28 '18 1D]2S >e Gnow that8 U 3 /G0 B U 1 /G0 U 2 /G0 U 3 /G0 B R128 '3D]8 '28 '3']S Convolution of two given sequences is8 ; 3 /n0 B I()*JU 3 /G0K &'1 ; 3 /n0 B /12&0 N U 3 /G0e ]2XGn2& n B ,8 18 28 O. 8 &'1 GB, 3 ; 3 /,0 B /1240 N U 3 /G0 B /1240 J12 P 3 D] '2 '3 P]K B 1
GB, 3 ; 3 /10 B /1240 N U 3 /G0e ]XG22 GB, ; 3 /10 B /1240 J12 D /'3 D ]0 ] D /'20 /'10 D /'3 ' ]0 /']0K B 3 3 ; 3 /20 B /1240 N U 3 /G0e ]XG GB, ; 3 /20 B /1240 J12 D /'3 D ]0 /'10 D /'20 /10 D /'3 ' ]0 /'10K B 4 35 3 ; 3 /30 B /1240 N U 3 /G0e ]3XG22 GB, ; 3 /30 B /1240 J12 D /'3 D ]0 /']0 D /'20 /'10 D /'3 ' ]0 /]0K B 4 Convolute! sequence of two given sequences is8 ; 3 /n0 B R18 38 48 4S 4rogram5 clcA @ Clear screen ;1 B input/H:nter the 1st seq5H0A @ Tet the first sequence ;2 B input/H:nter the 2n! seq5H0A @ Tet the secon! sequence n B length/;10 D length/;20'1A @ Tet the length of the sequence ;1 B fft/;18n0A @ Compute the ()* of ;1 using ))* algorithm ;2 B fft/;28n0A @ Compute the ()* of ;2 using ))* algorithm y B ;1.C;2A @ 3ultiply two ()*Fs yc B ifft/y8n0A @ Compute I()* using I))* algorithm !isp/HLinear convolution using ()* an! I()*5H0A @ (isplay Linear convolution !isp/yc0A @ (isplays the result on comman! win!ow & B ,515n'1A @ (efines the length of ;'a;is to plot the result su1plot/181810A @ (ivi!e the win!ow to plot the result stem/&8yc0A @ 4lots the result ;la1el/H*imeH0A @ &ame the ;'a;is as *ime yla1el/H3agnitu!eH0A @ &ame the y'a;is as 3agnitu!e title/HLinear convolution using ()* an! I()*5H0A @ *itle OUTPUT: :nter the 1st seq5 J1 1 2K :nter the 2n! seq5 J1 2K Linear convolution using ()* an! I()*5 1 3 4 4 36 0 0.5 1 1.5 2 2.5 3 0 0.5 1 1.5 2 2.5 3 3.5 4 Time M a g n i t u d e Linear convolution using DFT and IDFT: 37 EXPERIMENT NO-1> AIM: TO IMPLEMENT CIRCULAR CONVOLUTION OF T2O GIVEN SE3UENCES USING DFT AND IDFT Ci%0(la% 0$n5$l(!i$n: Let ; 1 /n0 an! ; 2 /n0 are finite !uration sequences 1oth of length & with ()*Fs U 1 /G0 an! U 2 /G0. Convolution of two given sequences ; 1 /n0 an! ; 2 /n0 is given 1y8 ; 3 /n0 B I()*JU 3 /G0K ; 3 /n0 B I()*JU 1 /G0 U 2 /G0K >here8 U 1 /G0 B ()* J; 1 /n0K U 2 /G0 B ()* J; 2 /n0K E,ampl#: ; 1 /n0 B R18 18 28 1S ; 2 /n0 B R18 28 38 4S &'1 U 1 /G0 B N ; 1 /n0e ']2XGn2& GB ,8 18 28 O 8 &'1 nB, Tiven ; 1 /n0 B R18 18 28 1S an! &B4
3 U 1 /,0 B N ; 1 /n0 B 1 D 1 D 2 D 1 B 5 nB, 3 U 1 /10 B N ; 1 /n0e ']Xn22 B 1 P ] P 2 D ] B '1 nB, 3 U 1 /20 B N ; 1 /n0e ']Xn B 1 P 1 D 2 ' 1 B 1 nB, 3 U 1 /30 B N ; 1 /n0e ']3Xn22 B 1 D ] ' 2 ' ] B '1 nB, 38 U 1 /G0 B R58 '18 18 '1S &ow8 &'1 U 2 /G0 B N ; 2 /n0e ']2XGn2& GB ,8 18 28 O 8 &'1 nB, Tiven ; 2 /n0 B R18 28 38 4S an! &B4 3 U 2 /,0 B N ; 2 /n0 B 1 D 2 D 3 D 4 B 1, nB,
3 U 2 /10 B N ; 2 /n0 e ']Xn22 B 1 D 2/']0 D 3/'10 D 4/]0 B '2 D ]2 nB, 3 U 2 /20 B N ; 2 /n0 e ']Xn B 1 D 2/'10 D 3/10 D 4/'10 B '2 nB, 3 U 2 /30 B N ; 2 /n0 e ']3Xn22 B 1 D 2/]0 D 3/'10 D 4/']0 B '2 P ]2 nB, U 2 /G0 B R1,8 '2D]28 '28 '2']2S >e Gnow that8 U 3 /G0 B U 1 /G0 U 2 /G0 U 3 /G0 B R5,8 2 P ]28 '28 2 D ]2S Convolution of two given sequences is8 ; 3 /n0 B I()*JU 3 /G0K &'1 ; 3 /n0 B /12&0 N U 3 /G0e ]2XGn2& n B ,8 18 28 O. 8 &'1 GB, 39 3 ; 3 /,0 B /1240 N U 3 /G0 B /1240 J5, D 2 ' ]2 P 2 D 2 D ]2K B 13
GB, 3 ; 3 /10 B /1240 N U 3 /G0e ]XG22 GB, ; 3 /10 B /1240 J5, D /2 ' ]20 ] D /'20 /'10 D /2 D ]20 /']0K B 14 3 ; 3 /20 B /1240 N U 3 /G0e ]XG GB, ; 3 /20 B /1240 J5, D /2 ' ]20 /'10 D /'20 /10 D /2 D ]20 /'10K B 11 3 ; 3 /30 B /1240 N U 3 /G0e ]3XG22 GB, ; 3 /30 B /1240 J5, D /2 ' ]20 /']0 D /'20 /'10 D /2 D ]20 /]0K B 12 Convolute! sequence of two given sequences is8 ; 3 /n0 B R138 148 118 12S P%$%am: clcA @ Clear screen ;1 B input/H:nter 1st sequence5H0A @ Tet the first sequence ;2 B input/H:nter 2n! sequence5H0A @ Tet the secon! sequence n B ma;/length/;108 length/;200A @ Tet the ma;imum length of the two sequences ;1 B fft/;18n0A @ Compute the ()* of the ;1 using ))* algorithm ;2 B fft/;28n0A @ Compute the ()* of the ;2 using ))* algorithm y B ;1.C;2A @ 3ultiply two ()*Fs yc B ifft/y8n0A @ Compute the I()* of mutliplie! sequence to get @ the convolute! sequence !isp/HCircular convolution using ()* an! I()*5H0A @ (isplays Circular convolution !isp/yc0A @ (isplays the result on comman! win!ow & B ,515n'1A @ (efines the length of ;'a;is to plot the result su1plot/181810A @ (ivi!e the win!ow to plot the result stem/&8yc0A @ 4lots the results ;la1el/H*imeH0A @ &ame the ;'a;is as 9*ime< yla1el/H3agnitu!eH0A @ &ame the y'a;is as 93agnitu!e< title/HCircular convolution using ()* an! I()*5H0A @ *itle 40 OUTPUT: :nter 1st sequence5J1 1 2 1K :nter 2n! sequence5J1 2 3 4K Circular convolution using ()* an! I()*5 13 14 11 12 0 0.5 1 1.5 2 2.5 3 0 5 10 15 Time M a g n i t u d e Circular convolution using DFT and IDFT: 41 EXPERIMENT NO-11 AIM: DESIGN AND IMPLEMENTATION OF FIR FILTER TO MEET GIVEN SPECIFICATIONS <LO2 PASS FILTER USING HAMMING 2INDO2= Fini!# Imp(l)# R#)p$n)# <FIR= Fil!#%: *he )I- filters are of non'recursive type8 where1y the present output sample is !epen!ing on the present input sample an! previous input samples. *he transfer function of a )I- causal filter is given 1y8 &'1 7/.0 B N h/n0. 'n nB, >here h/n0 is the impulse response of the filter. *he )ourier transform of h/n0 is &'1 7/e ]w 0 B Nh/n0e ']wn nB, In the !esign of )I- filters most commonly use! approach is using win!ows. *he !esire! frequency response 7 ! /e ]w 0 of a filter is perio!ic in frequency an! can 1e e;pan!e! in )ourier series. *he resultant series is given 1y8 X h ! /n0 B /122X0 ` 7/e ]w 0e ]wn !w 'X n! Gnown as )ourier coefficients having infinite length. Ine possi1le way of o1taining )I- filter is to truncate the infinite )ourier series at n B a J/&'1022K >here & is the length of the !esire! sequence. *he )ourier coefficients of the filter are mo!ifie! 1y multiplying the infinite impulse response with a finite weighing sequence w/n0 calle! a win!ow. >here w/n0 B w/'n0 b , for cnc [ J/&'1022K B , for cnc = J/&'1022K fter multiplying w/n0 with h ! /n08 we get a finite !uration sequence h/n0 that satisfies the !esire! magnitu!e response8 h/n0 B h ! /n0 w/n0 for cnc [ J/&'1022K B , for cnc = J/&'1022K 42 *he frequency response 7/e ]w 0 of the filter can 1e o1taine! 1y convolution of 7 ! /e ]w 0 an! >/e ]w 0 is given 1y8 X 7/e ]w 0 B /122X0 ` 7 ! /e ]d 0 >/e ]/w'd 0 !d 'X 7/e ]w 0 B 7 ! /e ]w 0 C >/e ]w 0 E,ampl#: 7ere we !esign a lowpass filter using hamming win!ow. 7amming win!ow function is given 1y8 w 7 /n0 B ,.54 D ,.4" cos //2Xn02/&'100 for P/&'1022 [ n [ /&'1022 B , otherwise *he frequency response of 7amming win!ow is8 > 7 /e ]w 0 B ,.54J/sin/w&22002/sin/w2200K D ,.23Jsin /w&22 P X&2& P 102sin /w22 P X2& '10K D ,.23Jsin /w&22 D X&2& P 102sin /w22 D X2& P 10K P%$%am: clcA @ Clear screen wp B input/H4ass 1an! e!ge freq5H0A @ Tet 4ass1an! e!ge frequency ws B input/H$top 1an! e!ge freq5H0A @ Tet $top1an! e!ge frequency tw B ws'wpA @ $u1tract 4W frequency from $W frequency & B ceil/"."Cpi2tw0D1A @ Compute length wn B /hamming/&00A @ -eturns &'point symmetric hamming win!ow in @ column vector W B fir1/&'18wp8wn0A @ (esigns /&'10 th or!er lowpass )I- filter an! @ returns filter coefficients in length & in vector W !isp/HImpulse response coeffBH0A @ (isplays Impulse response coefficients !isp/W0A @ (isplays the coefficients on comman! win!ow J78wK B freq./W81825"0A @ (igital filter frequency response. *his function @ returns the &'point comple; frequency response @ vector 7 an! the &'point frequency vector w in @ ra!ians2sample of the filter. 3ag B 2,Clog1,/a1s/700A @ Tet the magnitu!e plot/w2piCpi8 3ag0A @ 4lot the 3agnitu!e spectrum ;la1el/E)requency in ra!ians in terms of piH0A @ &ame ;'a;is yla1el/HTain in !1H0A @ &ame y'a;is as 9Tain in !1< 43 OUTPUT: 4ass 1an! e!ge freq5 ,.,5Cpi $top 1an! e!ge freq5 ,.4Cpi Impulse response coeffB Columns 1 through # ',.,,2# ',.,,35 ',.,,41 ',.,,1, ,.,1,5 ,.,333 ,.,""" Columns % through 14 ,.1,4" ,.13%3 ,.15%, ,.15%, ,.13%3 ,.1,4" ,.,""" Columns 15 through 2, ,.,333 ,.,1,5 ',.,,1, ',.,,41 ',.,,35 ',.,,2# 0 0.5 1 1.5 2 2.5 3 3.5 -100 -90 -80 -70 -60 -50 -40 -30 -20 -10 0 Frequency in radians in terms of pi G a i n
i n
d b 44 EXPERIMENT NO-1* AIM: DESIGN AND IMPLEMENTATION OF IIR FILTER TO MEET GIVEN SPECIFICATIONS Wasically !igital filter is a linear time'invariant !iscrete time system. In.ini!# Imp(l)# R#)p$n)#<IIR= .il!#%: II- filters are of recursive type8 where1y the present output sample !epen!s on the present input8 past input samples an! output samples. *he impulse response h/n0 for a reali.a1le filter is8 h/n0 B , for n[, n! for sta1ility8 it must satisfy the con!ition8 M N c h/n0 c Y M nB, E,ampl#: LetFs !esign an analog Wutterworth lowpass filter. $teps to !esign an analog Wutterworth lowpass filter. 1. )rom the given specifications fin! the or!er of the filter &. 2. -oun! off it to the ne;t higher integer. 3. )in! the transfer function 7/s0 for ec B 1ra!2sec for the value of &. 4. calculate the value of cutoff frequency ec 5. fin! the transfer function 7 a /s0 for the a1ove value of ec 1y su1stituting sf /s2 ec0 in 7/s0. P%$%am: clcA @ Clear screen 4a B input/H4ass1an! attenuation in (W5H0A @ Tet the pass1an! attenuation $a B input/H$top1an! attenuation in (W5H0A @ Tet the stop1an! attenuation )p1 B input/H4ass1an! e!ge frequency in 7.5H0A @ Tet 4ass1an! e!ge frequency )s1 B input/H$top1an! e!ge frequency in 7.5H0A @ Tet $top1an! e!ge frequency fs B input/H$ampling frequency5H0A @ Tet $ampling frequency wp B 2C)p12fsA @ Convert 4W e!ge frequency in 7. to ra!ians ws B 2C)s12fsA @ Convert $W e!ge frequency in 7. to ra!ians J&8wnK B 1uttor!/wp8ws84a8$a0A @ )in! cutoff frequency an! or!er of the filter !isp/HIr!er5H0A @ (isplay the Ir!er !isp/&0A @ (isplay or!er & on comman! win!ow !isp/HCutoff frequency5H0A @ (isplay Cutoff frequency !isp/wn0A @ (isplay Cutoff frequency on comman! win!ow 45 J18aK B 1utter/&8wn0A @ Tet &umerator an! !enominator coefficients of @ the filter !isp/H1BH0A !isp/10A @ (isplay the numerator coefficients on comman! @ win!ow !isp/HaBH0A !isp/a0A @ (isplay the !enominator coefficients on @ comman! win!ow w B ,5,.,15piA @ (efines length for ;'a;is to plot the result Jh8omK B freq./18a8w8HwholeH0A @ )requency response of the filter m B 2,Clog1,/a1s/h00A @ 1solute value of the frequency response vector an B angle/h0A @ Tet the phase of the frequency response vector su1plot/281810A @ (ivi!e the figure win!ow to plot the frequency @ response plot/om2pi8m0A @ 4lot the response ;la1el/H&ormalise! frequency5H0A @ &ame ;'a;is as 9&ormalise! frequency< yla1el/HTain in !15H0A @ &ame y'a;is as 9 Tain in !1< title/E)requency -esponse5F0A @ *itle as )requency -esponse su1plot/281820A @ (ivi!e the figure win!ow plot/om2pi8an0A @ 4lot the 4hase spectrum ;la1el/H&ormalise! frequency5H0A @ &ame ;'a;is as 9&ormalise! frequency< yla1el/H4hase in ra!ians5H0A @ &ame y'a;is as 4hase in ra!ians title/E4hase spectrumF0A @ *itle as 4hase spectrum OUTPUT: ass1an! attenuation in (W54 $top1an! attenuation in (W53, 4ass1an! e!ge frequency in 7.54,, $top1an! e!ge frequency in 7.5%,, $ampling frequency52,,, Ir!er5 3 Cutoff frequency5 ,.4+14 1B ,.1",, ,.4%,, ,.4%,, ,.1",, aB 1.,,,, ',.,4+4 ,.334, ',.,,45 46 47 48 P%$0#/(%# !$ S#!(p Em(la!$%5 1.Ipen the $etup CC$tu!io v3.1 Setup CCStudio v3.1.lnk 49 2. $elect Create Woar! /3arGe! in Circle8 can witness in the 1elow )igure0 Chose this option 50 3. -ight ClicG on the *I U($51, emulator an! select a!! to system.. :nter8 /fter selecting that options a Connection 4roperties win!ow will 1e opene! as shown in step 40. 51 4. 4rovi!e Connection &ame as Chip3a;\"#13 an! clicG on &e;t. 5. Choose the option )alling e!ge is g*T $tan!ar! in *3$2*(I Iutput *iming.
52 ". -ight ClicG on *3$32,C"#1, an! $elect !! to $ystemO:nter. 53 #. a0 4rovi!e 4rocessor &ame as *3$32,C"#13\, 10 $elect T:L )ile8 ClicG on 1rowse icon an! select ($4"21;\"#1;.gel. c0 $elect &2 in 3aster2$lave. !0 ClicG on IG. 54 %. ClicG on $ave an! quit /highlighte! 1y Circle0. +. ClicG on hes to start Co!e Composer $tu!io. 55 1,. To to (e1ug an! select the option connect. 56 57 11. &ow *arget is connecte! 58 E,p#%im#n! 1: Lin#a% C$n5$l(!i$n P%$0#/(%# !$ 0%#a!# n#7 P%$?#0!: 1. *o create pro]ect8 To to 4ro]ect an! $elect &ew. 2. Tive pro]ect name an! clicG on finish. / N$!#: Location must 1e c5iCC$tu!io\v3.1i3y4ro]ects 0. 59 3. ClicG on )ile &ew $ource )ile8 *o write the $ource Co!e. 60 Aim5 Linear Convolution of the two given sequences Ma!"#ma!i0al F$%m(la: *he linear convolution of two continuous time signals ;/t0 an! h/t0 is !efine! 1y )or !iscrete time signals ;/n0 an! h/n08 is !efine! 1y >here ;/n0 is the input signal an! h/n0 is the impulse response of the system. In linear convolution length of output sequence is8 Length /y/n00 B length/;/n00 D length/h/n00 P 1 P%$%am: jinclu!eYst!io.h= main/0 R int mB4A 2CLenght of i2p samples sequenceC2 int nB4A 2CLenght of impulse response Co'efficients C2 int iB,8]A int ;J1,KBR18283848,8,8,8,SA 2CInput $ignal $amplesC2 int hJ1,KBR18283848,8,8,8,SA 2CImpulse -esponse Co'efficientsC2 2Ct the en! of input sequences pa! H3H an! H&H no. of .eroHsC2 int CyA yB/int C0,;,,,,1,,A for/iB,AiYmDn'1AiDD0 R yJiKB,A for/]B,A]YBiA]DD0 yJiKDB;J]KChJi']KA S for/iB,AiYmDn'1AiDD0 printf/k@!ink8yJiK0A S O(!p(!: 1@ 4@ 1>@ *>@ *6@ *4@ 18. 61 4. :nter the source co!e an! save the file with 9 .CA e;tension. 5. -ight clicG on source8 $elect a!! files to pro]ect .. an! Choose 9.C 9 file $ave! 1efore. 62 ". -ight ClicG on li1raries an! select a!! files to 4ro]ect.. an! choose C5iCC$tu!io\v3.1iC",,,icgtoolsili1irts"#,,.li1 an! clicG open. 63 #. a0To to 4ro]ect to Compile . 10 To to 4ro]ect to Wuil!. c0 To to 4ro]ect to -e1uil! ll.
64 7ere it shows error if any %. To to file an! loa! program an! loa! B.$(!A file into the 1oar!..
65 +. To to (e1ug an! clicG on run to run the program. 66 1,. I1serve the output in output win!ow.
67 11. *o see the Traph go to View an! select time2frequency in the Traph8 n! give the correct $tart a!!ress provi!e! in the program8 (isplay !ata can 1e taGen as per user. 68 12. Treen line is to choose the point8 Value at the point can 1e seen /7ighlighte! 1y circle at the left corner0. 69 E,p#%im#n! *: Ci%0(la% C$n5$l(!i$n P%$0#/(%# !$ 0%#a!# n#7 P%$?#0!: 1. *o create pro]ect8 go to 4ro]ect an! $elect &ew. 2. Tive pro]ect name an! clicG on finish. / N$!#: Location must 1e c5iCC$tu!io\v3.1i3y4ro]ects 0. 70 3. ClicG on )ile &ew $ource )ile8 to write the $ource Co!e. 71 AIM 5 *o implement circular convolution of two sequences. Ci%0(la% C$n5$l(!i$n: Let ;1/n0 an! ;2/n0 are finite !uration sequences 1oth of length & with ()*Fs U1/G0 an! U2/G0. Convolution of two given sequences ;1/n0 an! ;2/n0 is given 1y the equation8 ;3/n0 B I()*JU3/G0K U3/G0 B U1/G0 U2/G0 &'1 ;3/n0 C D ;1/m0 ;2//n'm00& mB, P%$%am: jinclu!eYst!io.h= int m8n8;J3,K8hJ3,K8yJ3,K8i8]8tempJ3,K8G8;2J3,K8aJ3,KA voi! main/0 R int CyA yB/int C0,;,,,,1,,A printf/k enter the length of the first sequenceink0A scanf/k@!k8lm0A printf/k enter the length of the secon! sequenceink0A scanf/k@!k8ln0A printf/k enter the first sequenceink0A for/iB,AiYmAiDD0 scanf/k@!k8l;JiK0A printf/k enter the secon! sequenceink0A for/]B,A]YnA]DD0 scanf/k@!k8lhJ]K0A if/m'nmB,0 2CIf length of 1oth sequences are not equalC2 R if/m=n0 2C 4a! the smaller sequence with .eroC2 R for/iBnAiYmAiDD0 hJiKB,A nBmA S for/iBmAiYnAiDD0 ;JiKB,A mBnA S yJ,KB,A 72 aJ,KBhJ,KA for/]B1A]YnA]DD0 2Cfol!ing h/n0 to h/'n0C2 aJ]KBhJn']KA EFCi%0(la% 0$n5$l(!i$nFE for/iB,AiYnAiDD0 yJ,KDB;JiKCaJiKA for/GB1AGYnAGDD0 R yJGKB,A 2Ccircular shiftC2 for/]B1A]YnA]DD0 ;2J]KBaJ]'1KA ;2J,KBaJn'1KA for/iB,AiYnAiDD0 R aJiKB;2JiKA yJGKDB;JiKC;2JiKA S S EF/i)pla&in !"# %#)(l!FE printf/k the circular convolution isink0A for/iB,AiYnAiDD0 printf/k@! k8yJiK0A S O(!p(!: enter the length of the first sequence 4 enter the length of the secon! sequence 4 enter the first sequence 4 3 2 1 enter the secon! sequence 1 1 1 1 the circular convolution is 1, 1, 1, 1, 73 4. :nter the source co!e an! save the file with 9 .CA e;tension. 5. -ight clicG on source8 $elect a!! files to pro]ect .. an! Choose 9.C 9 file $ave! 1efore. 74 ". -ight ClicG on li1raries an! select a!! files to 4ro]ect.. an! choose C5iCC$tu!io\v3.1iC",,,icgtoolsili1irts"#,,.li1 an! clicG open. 75 76 #. a0 To to 4ro]ect to Compile . 10 To to 4ro]ect to Wuil!. c0 To to 4ro]ect to -e1uil! ll. 77 In case of any errors or warnings it will 1e !isplaye! here %. To to file an! loa! program an! loa! B.$(!A file into the 1oar!.. 78 +. To to (e1ug an! clicG on run to run the program. 79 1,. :nter the input !ata to calculate the circular convolution. 80 *he correspon!ing output will 1e shown on the output win!ow as shown 1elow 81 82 11. *o see the Traph go to View an! select time2frequency in the Traph8 an! give the correct $tart a!!ress provi!e! in the program8 (isplay !ata can 1e taGen as per user. 83 12. 12. Treen line is to choose the point8 Value at the point can 1e seen /7ighlighte! 1y circle at the left corner0. 84 E,p#%im#n! 1: N-P$in! DFT P%$0#/(%# !$ 0%#a!# n#7 P%$?#0!: 1. *o create pro]ect8 To to 4ro]ect an! $elect &ew. 2. Tive pro]ect name an! clicG on finish. / N$!#: Location must 1e c5iCC$tu!io\v3.1i3y4ro]ects 0. 85 3. ClicG on )ile &ew $ource )ile8 *o write the $ource Co!e. 86 AIM5 *I CI34?*: &'4II&* ()* I) TIV:& $:n?:&C: &( *I 4LI* 3T&I*?(: &( 47$: $4:C*-?3. Di)0%#!# F$(%i#% T%an).$%m: *he (iscrete )ourier *ransform is a powerful computation tool which allows us to evaluate the )ourier *ransform U/e ]^ 0 on a !igital computer or specially !esigne! !igital har!ware. $ince U/e ]^ 0 is continuous an! perio!ic8 the ()* is o1taine! 1y sampling one perio! of the )ourier *ransform at a finite num1er of frequency points. part from !etermining the frequency content of a signal8 ()* is use! to perform linear filtering operations in the frequency !omain. *he sequence of N comple; num1ers x,8...8 xN_1 is transforme! into the sequence of N comple; num1ers X,8 ...8 XN_1 1y the ()* accor!ing to the formula5 &'1 U/G0 B N;/n0e ']2XnG2& G B ,818 O. &'1 nB, P%$%am: 22()* of &'point from looGup ta1le. Iutput from watch win!ow jinclu!e Yst!io.h= jinclu!e Ymath.h= j!efine & 4 22num1er of !ata values float pi B 3.141"A short ;J&K B R1818,8,SA 221'cycle cosine float outJ2K B R,8,SA 22initiali.e -e an! Im results voi! !ft/short C;8 short G8 float Cout0 22()* function R float sum-e B ,A 22initiali.e real component float sumIm B ,A 22initiali.e imaginary component int i B ,A float cs B ,A 22initiali.e cosine component float sn B ,A 22initiali.e sine component for /i B ,A i Y &A iDD0 22for &'point ()* R cs B cos/2CpiC/G0Ci2&0A 22real component sn B sin/2CpiC/G0Ci2&0A 22imaginary component sum-e B sum-e D ;JiKCcsA 22sum of real components sumIm B sumIm ' ;JiKCsnA 22sum of imaginary components S outJ,K B sum-eA 22sum of real components outJ1K B sumImA 22sum of imaginary components 87 printf/k@f @fink8outJ,K8outJ1K0A S voi! main/0 R int ]A for /] B ,A ] Y &A ]DD0 !ft/;8 ]8 out0A 22call ()* function S O(!p(!: 2.,,,,,, ,.,,,,,, ,.+++++" '1.,,,,,, ,.,,,,,, ,.,,,,,# 1.,,,,11 1.,,,,,, 88 4. :nter the source co!e an! save the file with 9 .CA e;tension. 89 5. -ight clicG on source8 $elect a!! files to pro]ect .. an! Choose 9.C 9 file $ave! 1efore. 90 ". -ight ClicG on li1raries an! select a!! files to 4ro]ect.. an! choose C5iCC$tu!io\v3.1iC",,,icgtoolsili1irts"#,,.li1 an! clicG open. 91 #. a0 To to 4ro]ect to Compile . 10 To to 4ro]ect to Wuil!. c0 To to 4ro]ect to -e1uil! ll.
92 7ere it shows error if any It will shows warnings an! errors if any %. To to file an! loa! program an! loa! B.$(!A file into the 1oar!..
93 +. To to (e1ug an! clicG on run to run the program. 94 1,. I1serve the output in output win!ow. 95 Iutput will shown here 11. *o see the Traph go to View an! select time2frequency in the Traph8 n! give the correct $tart a!!ress provi!e! in the program8 (isplay !ata can 1e taGen as per user. 96 12. Treen line is to choose the point8 Value at the point can 1e seen /7ighlighte! 1y circle at the left corner0. 97 E,p#%im#n! 4: FIR FILTER P%$0#/(%# !$ 0%#a!# n#7 P%$?#0!: 1. *o create pro]ect8 To to 4ro]ect an! $elect &ew. 2. Tive pro]ect name an! clicG on finish. 98 / N$!#: Location must 1e c5iCC$tu!io\v3.1i3y4ro]ects 0. 3. ClicG on )ile &ew $ource )ile8 *o write the $ource Co!e. 99 AIM: -eali.ation of )I- filter /any type0 to meet given specifications. *he input can 1e a signal from )unction Tenerator2$peech signal 100 Fini!# Imp(l)# R#)p$n)# <FIR= Fil!#%: *he )I- filters are of non'recursive type8 where1y the present output sample is !epen!ing on the present input sample an! previous input samples. *he transfer function of a )I- causal filter is given 1y8 &'1 7/.0 B N h/n0. 'n nB, >here h/n0 is the impulse response of the filter. *he )ourier transform of h/n0 is &'1 7/e ]w 0 B Nh/n0e ']wn nB, In the !esign of )I- filters most commonly use! approach is using win!ows. *he !esire! frequency response 7 ! /e ]w 0 of a filter is perio!ic in frequency an! can 1e e;pan!e! in )ourier series. *he resultant series is given 1y8 X h ! /n0 B /122X0 ` 7/e ]w 0e ]wn !w 'X n! Gnown as )ourier coefficients having infinite length. Ine possi1le way of o1taining )I- filter is to truncate the infinite )ourier series at n B a J/&'1022K >here & is the length of the !esire! sequence. *he )ourier coefficients of the filter are mo!ifie! 1y multiplying the infinite impulse response with a finite weighing sequence w/n0 calle! a win!ow. >here w/n0 B w/'n0 b , for cnc [ J/&'1022K B , for cnc = J/&'1022K fter multiplying w/n0 with h ! /n08 we get a finite !uration sequence h/n0 that satisfies the !esire! magnitu!e response8 h/n0 B h ! /n0 w/n0 for cnc [ J/&'1022K B , for cnc = J/&'1022K *he frequency response 7/e ]w 0 of the filter can 1e o1taine! 1y convolution of 7 ! /e ]w 0 an! >/e ]w 0 is given 1y8 X 7/e ]w 0 B /122X0 ` 7 ! /e ]d 0 >/e ]/w'd 0 !d 'X 7/e ]w 0 B 7 ! /e ]w 0 C >/e ]w 0 P%$%am: jinclu!e Yst!io.h= jinclu!e kc"#13!sG.hk 101 jinclu!e kmaster.hk jinclu!e kaic23cfg.hk jinclu!e k!sG"#13\aic23.hk jinclu!e Yst!.h= jinclu!e Yswi.h= jinclu!e Ylog.h= jinclu!e Yc";.h= jinclu!e Ycsl.h= jinclu!e Ycsl\mc1sp.h= 2C Length of sine wave ta1le C2 j!efine $I&:\*WL:\$Io: 4% 22 (elta 2Cfloat filter\CoeffJK BR,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8 ,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8 ,.,,8,.,,8,.,,8,.,,8,.,,8,.,,81.,,8,.,,SAC2 22 Low 4ass )ilter 2Cfloat filter\CoeffJK BR2.#152+#"341#114"e',,38 2.315%1+%,2+42+24e',,48' 1.2444+35%13#3"43e',,28 #.2443"4+1#2214,1e',,381.2,#341#1"154354e',,28 2.#341341""5%5232e',,38 '1.+41#,"44,#+,"#%e',,28 '1.#2+,+%21%%4322"e',,281.##3,,%#3,5"%"#5e',,28 4.,+14+51#4,5+34+e',,282.11343"#5113"+44e',,38 '".#%%4"%54+##1#3,e',,28 '".,5+44,#,,5#,#+1e',,28 %.+#,31325"44%2""e',,283.,145#2+4+3#4"25e',,18 4.,1+,,+4542+++"%e',,183.,145#2+4+3#4"25e',,18 %.+#,31325"44%2""e',,28 '".,5+44,#,,5#,#+1e',,28 '".#%%4"%54+##1#3,e',,282.11343"#5113"+44e',,38 4.,+14+51#4,5+34+e',,281.##3,,%#3,5"%"#5e',,28 '1.#2+,+%21%%4322"e',,28 '1.+41#,"44,#+,"#%e',,28 2.#341341""5%5232e',,381.2,#341#1"154354e',,28 #.2443"4+1#2214,1e',,38'1.2444+35%13#3"43e',,28 2.315%1+%,2+42+24e',,48 2.#152+#"341#114"e',,3SAC2 22 7igh 4ass )ilter float filter\CoeffJK BR3.2+431"42,#,2"+"e',,483.%,,,2,,#"4%"443e' ,,38+.%222,,%,"#3+,14e',,381.51#2"5313%%+1"#e',,28 1.32354#,,#544+,%e',,282."35%+"+%",4%+1+e',,48'1.%,%215#3##34512e',,28' 2."""%33,132"+#5%e',,28 '1.155354+"22#,,25e',,282.44%211%"""5"4,,e',,285.5341,1,55#%3%+5e' ,,284.42435+,%#1+%%+"e',,28 '2.+2232+551555#5#e',,28'1.4#3332,22"%+2"1e',,18'2.5#4"25"5+,#3+34e' ,,18".+#"2,31,+1254+3e',,18 '2.5#4"25"5+,#3+34e',,18'1.4#3332,22"%+2"1e',,18'2.+2232+551555#5#e' ,,284.42435+,%#1+%%+"e',,28 5.5341,1,55#%3%+5e',,282.44%211%"""5"4,,e',,28'1.155354+"22#,,25e',,28' 2."""%33,132"+#5%e',,28 102 '1.%,%215#3##34512e',,282."35%+"+%",4%+1+e',,481.32354#,,#544+,%e' ,,281.51#2"5313%%+1"#e',,28 +.%222,,%,"#3+,14e',,383.%,,,2,,#"4%"443e',,383.2+431"42,#,2"+"e',,4SA 22 4re'generate! sine wave !ata8 1"'1it signe! samples int sineta1leJ$I&:\*WL:\$Io:K B R ,;,,,,8 ,;1,148 ,;212,8 ,;3,f18 ,;3fff8 ,;4!ea8 ,;5a%18 ,;"5%18 ,;"e!%8 ,;#"3f8 ,;#1a18 ,;#ee58 ,;#ff!8 ,;#ee58 ,;#1a18 ,;#"ef8 ,;"e!%8 ,;"5%18 ,;5a%18 ,;4!ea8 ,;3fff8 ,;3,f18 ,;212,8 ,;1,148 ,;,,,,8 ,;ef4c8 ,;!ee,8 ,;cf,"8 ,;c,,28 ,;121"8 ,;a5#f8 ,;+a#58 ,;+12%8 ,;%+c18 ,;%45f8 ,;%1118 ,;%,,28 ,;%1118 ,;%45f8 ,;%+c18 ,;+12%8 ,;+a#"8 ,;a5#f8 ,;121"8 ,;c,,28 ,;cf,"8 ,;!ee,8 ,;ef4c SA ($6"#13\IC23\Config config B R i ,;,,1#8 2C , ($6"#13\IC23\L:)*I&VIL Left line input channel volume C2 i ,;,,1#8 2C 1 ($6"#13\IC23\-IT7*I&VIL -ight line input channel volume C2i ,;,,!%8 2C 2 ($6"#13\IC23\L:)*74VIL Left channel hea!phone volume C2 i ,;,,!%8 2C 3 ($6"#13\IC23\-IT7*74VIL -ight channel hea!phone volume C2 i 22 ,;,,14 micin with ,!W 1oost ,;,,148 2C 4 ($6"#13\IC23\&4*7 nalog au!io path control C2 i ,;,,,,8 2C 5 ($6"#13\IC23\(IT4*7 (igital au!io path control C2 i ,;,,,,8 2C " ($6"#13\IC23\4I>:-(I>& 4ower !own control C2 i ,;,,438 2C # ($6"#13\IC23\(ITI) (igital au!io interface format C2 i ,;,,%c8 2C % ($6"#13\IC23\$34L:-*: $ample rate control C2 i ,;,,,1 2C + ($6"#13\IC23\(ITC* (igital interface activation C2 i SA ($6"#13\IC23\Co!ec7an!le hCo!ecA Int32 Init>ait B1A Int32 !ataA Int32 LoggerJ1,24KA Int32 LoggerIn!e; B,A float in\1ufferJ1,,KA main/0R int iA L:(B,;,A 22 )ilter Initiali.ation for/ i B , A i Y 1,,A iDD 0 in\1ufferJiKB,.,A 22 Initiali.e co!ec hCo!ec B ($6"#13\IC23\openCo!ec/,8 lconfig0A I-n\glo1al:na1le/0A 103 I-n\ena1le/I-n\:V*\-I&*10A I-n\ena1le/I-n\:V*\UI&*10A S voi! le!/0R static int cc B 1A L:( B ccA 22 *o $hift 4attern if /cc BB ,;,30 cc B ,;,5A else if /cc BB ,;,50 cc B ,;,"A else if /cc BB ,;,"0 cc B ,;,3A else cc B ,;,3A 22*o count Winary 22ccDDA if /cc=,;,#0 cc B ,;,,A 22 *I *oggle L:( 22 Ccc pB ,;,#A if //cc mB,;,,0 ll /cc mB,;,#00 cc B ,;,#A S setpll2,,3/0R S voi! rea!/0R int i B ,A float resultA !ataB3CW$4\rea!/($6"#13\IC23\(*7&(L:0A if/!ata=B32#"%0 !ataB !atac,;ffff,,,,A for/ i B ,A i YB 2+A iDD0 in\1ufferJiK B in\1ufferJiD1KA in\1ufferJ3,KB//float0/!ata0021"A result B ,A for/ i B , A i YB 3,A iDD 0 result DB filter\CoeffJiK C in\1ufferJiKA !ata B /Int320/resultC5120A 22!ata B /Int320/in\1ufferJ3,KC1"0A LoggerJLoggerIn!e;DDK B !ataA if /LoggerIn!e; BB 1,240 LoggerIn!e; B ,A S voi! write/0R if /Init>aitY1,,,0R Init>aitDDA 3CW$4\write/($6"#13\IC23\(*7&(L:8 ,0A 104 3CW$4\write/($6"#13\IC23\(*7&(L:8 ,0A S elseR 3CW$4\write/($6"#13\IC23\(*7&(L:8 !ata0A 3CW$4\write/($6"#13\IC23\(*7&(L:8 !ata0A S S Iutput5 4. :nter the source co!e an! save the file with main.c e;tension. 105 5. -ight clicG on source8 $elect a!! files to pro]ect an! Choose main.c file $ave! 1efore. ". !! the other supporting .c files which configure the au!io co!ec. 106 #. #. a0 To to 4ro]ect to Compile. 10 To to 4ro]ect to Wuil!. c0 To to 4ro]ect to -e1uil! ll. 107 %. To to file an! loa! program an! loa! B.$(!A file into the 1oar!. +. To to (e1ug an! clicG on run to run the program. 108 It will shows warnings an! errors if any 109 1,. *o see the Traph go to View an! select time2frequency in the Traph an! give the correct $tart a!!ress provi!e! in the program8 (isplay !ata can 1e taGen as per user. 110 11. Treen line is to choose the point8 Value at the point can 1e seen /7ighlighte! 1y circle at the left corner0. 12. In the graph8 chose ))* magnitu!e as !isplay type we will get Traph W 111 Traph 25))* magnitu!e of )I- filter. 13. *he impulse response of )I- filters. 112 113 E,p#%im#n! 8: N$i)# R#m$5al P%$0#/(%# !$ 0%#a!# n#7 P%$?#0!: 1. *o create pro]ect8 To to 4ro]ect an! $elect &ew. 2. Tive pro]ect name an! clicG on finish. 114 / N$!#: Location must 1e c5iCC$tu!io\v3.1i3y4ro]ects 0. 3. ClicG on )ile &ew $ource )ile8 *o write the $ource Co!e. 115 AIM: &oise removal in a given mi;e! signal. N$i)# %#m$5al: In the real time systems every signal will get corrupte! 1y the noise. *o analy.e the noise we nee! to a!! the noise8 a noise will 1e generate! an! a!!e! to the signal. noise of 367. is a!!e! to a tone of 4,,67. then the noise is remove! 1y using an high pass filter.
float filter\CoeffJ32K BR,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8 ,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8,.,,8 ,.,,8,.,,8,.,,8,.,,8,.,,8,.,,81.,,8,.,,SA float 4r&oiseJ",,KBR,.35,+8,.111%8,.3"318,.2"#38,.2%2"8,.1+,+8,.2+,18,.13#%8,.12#,8 ,.1#+%8,.2+258,.3#3,8,.13,#8,.13%,8,.2%5+8,.1#3%8,.32#%8,.,3558,.31##8,.2+,58 ,.14#38,.23%,8,.21128,.2""28,.322%8,.,2"48,.2++18,.3,2#8,.122,8,.1"#"8 ,.23",8,.2+428,.3,5%8,.3,138,.14238,.14#%8,.34#+8,.2,1#8,.32#%8,.11"48 ,.2#4#8,.2#528,.423+8,.,"""8,.213,8,.21248,.,1248,.33,"8,.31348,.142,8 ,.2%3#8,.,44"8,.243%8,.1,"+8,.1+,28,.34+#8,.,+"28,.14,48,.2,4"8,.141+8 ,.32318,.3+"28,.,54+8,.,%#58,.2#428,.141%8,.3#+#8,.3#5"8,.24418,.32#18 ,.145"8,.23328,.3#%+8,.225,8,.3#+%8,.31538,.22+58,.2+5,8,.3+248,.,+%28 ,.14+38,.3"4+8,.115+8,.2,+58,.3,%%8,.3"5"8,.253+8,.,","8,.,54%8,.2%4#8 ,.2"1,8,.4,,58,.2+%58,.245+8,.1#%+8,.,%248,.3##48,.225"8,.,3,+8,.2+4+8 ,.21338,.,13"8,.32%%8,.,+238,.,4+18,.,1#%8,.12,58,.11,#8,.3,428,.,#"18 ,.15128,.13,28,.34348,.13%48,.24548,.1%#38,.2%,48,.,4,#8,.41"48,.3%5%8 ,.,"#%8,.22#58,.143,8,.23,48,.,5,,8,.1#+38,.1%%#8,.2,"#8,.1##"8,.,3#48 ,.244+8,.2,+38,.,##28,.1+%28,.1#%#8,.2,218,.2+1"8,.255#8,.33,48,.,1%48 ,.,%+28,.1%238,.3#"28,.2+%48,.15#"8,.112,8,.,,%%8,.3,2"8,.22#48,.12238 ,.21518,.11318,.324%8,.14418,.34#58',.,4#18,.2#4+8,.1+258,.1#,%8,.24318 ,.2+#58,.,"348,.3%+18,.,3#28,.14%"8,.,+438,.3%358,.,3558,.232,8,.24""8 116 ,.242%8,.31#58',.,1,58,.2%+18,.1#"48,.2"218,.,%148,.223+8,.3,#48,.41+"8 ,.2,"58,.,"138,.,3218,.24+58,.3,448,.25138,.11+38,.3"358,.2,318,.3%,18 ,.,3,38,.,#338,.3,,18,.35,#8,.2+%58,.11%"8,.,"5"8,.3"128,.33+#8,.12+48 ,.11,28,.11+48,.3,258,.2%+28,.1%458,.1+5"8,.1,#38,.2+%18,.3"%28,.23118 ,.22448,.2,++8,.,++,8,.222,8,.2%+48,.2%138,.231"8,.,"538,.2%#28,.1,4%8 ,.13358,.1"3+8,.13358,.2#528,.,2"28,.2+5%8,.222"8,.2+1"8,.11428,.2,1#8 ,.32528,.2,+38,.12%,8,.43358,.,"2#8,.1%5,8,.43%%8,.1%218,.14518,.,5448 ,.34"28,.,1548,.,%228,.3,318,.14#%8,.213,8,.223,8,.2%+#8,.,3+#8,.243"8 ,.,42%8,.35518,.145%8,.33%28,.,+5#8,.23,38,.3%,48,.,2"28,.,35"8,.,13,8 ,.2",#8,.21,28',.,,2,8,.25%18,.1+338',.,,4#8,.,2448,.,+228,.3%,58,.1,+28 ,.1"#,8,.144#8,.,4##8,.3,##8,.21248,.21248,.1%#+8,.1"238,.121+8,.2+,48 ,.,+538,.11328,.,5,28,.4,,28,.3#"58,.,,+"8,.144,8,.22+18,.1,2#8,.31148 ,.25%,8,.2,%+8,.14348,.31"%8,.35,38,.25518,.1,"48,.312#8,.,5%%8,.1+2"8 ,.3%"#8,.141%8,.153%8,.42418,.,"5+8,.143%8,.22%"8,.,5,%8,.2,#28,.2#4,8 ,.1"%%8,.241"8,.,%2#8,.23148,.34+"8,.1+348,.3%%"8,.,%+48,.,#,48,.14+38 ,.1%438,.1%5+8,.12528,.255+8,.,,358,.121#8,.,#1#8,.,+128,.,2518,.24,58 ,.143"8,.1,#48,.,4+38,.15528,.245"8,.35"58',.,1"#8,.3,258',.,1%#8,.2##28 ,.2%1"8,.35%28,.,#5,8,.24228,.21"+8,.121,8,.2"348,.24248,.,",,8,.1"318 ,.32+38,.13%38,.23#18,.15518,.,33%8,.15+38,.3#2,8,.1%128,.,",#8,.1+++8 ,.12,"8,.24118,.1"358,.2#2#8,.2+5%8,.,#5%8,.,#,18,.35"58,.2%%,8,.,3"38 ,.3#2"8,.2,,28,.2,,38,.212#8,.2#"%8,.314"8,.14,,8,.,2+18,.2+3"8,.13418 ,.33#58,.15448,.33218,.,#1"8,.,5328,.34#38,.,1#"8,.2"#18,.2##28,.1"1#8 ,.12"48,.3"%%8,.14#58,.1#"%8,.,#"48,.155"8,.153+8,.3"%48,.,+#+8,.1,128 ,.12"18,.24,18,.,1538,.32348,.,3#38,.2,528,.,4"58,.34,58,.3,5"8,.,+,18 ,.25%58,.1#4"8,.2+,58,.1#+58,.33""8,.1#448,.1"1%8,.23#28,.14218,.3+3#8 ,.1+2#8,.,#",8,.124%8,.23"#8,.115+8,.,4318,.335,8,.24528,.1%,,8,.12348 ,.11338,.21"48,.1#428,.2#%38,.,,538,.31%,8,.251%8,.,3%"8,.32#,8,.,",+8 ,.22#38,.2,",8,.,4##8,.,,2+8,.31%28,.321%8,.1+%,8,.,4%38,.25328,.,#,48 ,.2"%%8,.1%,58,.,"348,.33,48,.2%1"8,.34#,8,.,3+"8,.,%228,.3,##8,.2%128 ,.2+,"8,.1"5+8,.14""8,.22#%8,.35",8,.3,+58,.2"#18,.1#+%8,.333+8,.1"128 ,.1+"#8,.2#558,.22258,.24%38,.3,138,.2+418,.,2,18,.,%,#8,.13+58,.21148 ,.,+118,.213#8,.113,8,.14358,.2%1#8,.,31,8,.,"#%8,.31,#8,.142+8,.,%148 ,.242+8,.3#128,.15%#8,.2"228,.21"+8,.15,38,.1%348,.3%+#8,.,%4"8,.1#,38 ,.23418,.2"318,.34128,.13448,.,+,38,.1++38,.,+3+8,.2%4#8,.1"+#8,.23128 ,.2#"18,.1#538,.11+,8,.,%"%8,.3%"48,.,%138,.3,238,.21458,.2#"48,.314%8 ,.,,%"8,.132+8,.3+528,.2"%48,.3%438,.21%18,.,22"8,.2"%18,.1,%,8,.224+8 ,.2%328,.23+58,.21+38,.15+,8,.,""38,.14#48',.,1"38,.22",8,.3#2#8,.,3,38 ,.,2358,.3"2#8,.1,"28,.,,%48,.324"8,.,5"%8,.34%58,.,4,#8,.13538,.233%8 ,.23158,.25458,.24%28,.151,8,.,3"38,.2%%28,.,+258,.2",38,.34448,.,4458 ,.4,348,.,1"28,.331+8,.32128,.,,""8,.2,1,8,.3",48,.112,8,.31558,.23+,8 ,.32318,.33,18,.,2"+8,.113%8,.252,8,.1%#58,.3##%8,.2+3+8,.21338,.11#,8 ,.,+##8,.35248,.1""48,.32118,.,2528,.33"18,.,,238,.35138,.3"%"8,.21518 ,.,5%18,.,###8,.1""48,.32118,.,2528,.33"18,.,,238,.35138,.3"%"8,.2151SA float -em&oiseJ4#KBR '2.1%1,3,"2+,"2+,%e',,28%.+1#42%2115"425"e',,38 1.1%2%"313,+"3+4#e',,281.42%4533#5#4%1,"e',,281.4,335,%14552515e',,28 117 1.,3+%5","#"4+,"#e',,28 5.,+32#42,,2#5%2#e',,381.4215%12"231%%43e',,38 2.51543,+3"5##3"%e',,38+.3"3,5321311112"e',,381.+4+15211244""23e',,28 2.#22%+#"+%"%4+#2e',,282.5#++4323##,,51#e',,281.,5,"451+1333"#5e',,28 '1.%321"3++%",43+#e',,28'5.4,"1+41%1,33"4,e',,28'%.514%"+#235%4"1"e',,28 '+.%%#"1%###1+4#"4e',,28'%."33153232%2,#5%e',,28'4."51515,2451#2"1e',,28 1.21#,11"1,"2+542e',,28#.3+4%3%432,%%444e',,281.2,"%,2"1"4,+422e',,18 1.3%,"243###2+,+4e',,181.2,"%,2"1"4,+422e',,18#.3+4%3%432,%%444e',,28 1.21#,11"1,"2+542e',,28'4."51515,2451#2"1e',,28'%."33153232%2,#5%e',,28 '+.%%#"1%###1+4#"4e',,28'%.514%"+#235%4"1"e',,28'5.4,"1+41%1,33"4,e',,28 '1.%321"3++%",43+#e',,281.,5,"451+1333"#5e',,282.5#++4323##,,51#e',,28 2.#22%+#"+%"%4+#2e',,281.+4+15211244""23e',,28+.3"3,5321311112"e',,38 2.51543,+3"5##3"%e',,381.4215%12"231%%43e',,385.,+32#42,,2#5%2#e',,38 1.,3+%5","#"4+,"#e',,281.4,335,%14552515e',,281.42%4533#5#4%1,"e',,28 1.1%2%"313,+"3+4#e',,28%.+1#42%2115"425"e',,38'2.1%1,3,"2+,"2+,%e',,2SA int sineta1leJ$I&:\*WL:\$Io:K B R,;,,,,,,,,8 ,;,,,,1,148 ,;,,,,212,8 ,;,,,,3,f18 ,;,,,,3fff8 ,;,,,,4!ea8 ,;,,,,5a%18 ,;,,,,"5%18 ,;,,,,"e!%8 ,;,,,,#"3f8 ,;,,,,#1a18 ,;,,,,#ee58 ,;,,,,#ff!8 ,;,,,,#ee58 ,;,,,,#1a18 ,;,,,,#"ef8 ,;,,,,"e!%8 ,;,,,,"5%18 ,;,,,,5a%18 ,;,,,,4!ea8 ,;,,,,3fff8 ,;,,,,3,f18 ,;,,,,212,8 ,;,,,,1,148,;,,,,,,,,8 ,;ffffef4c8 ,;ffff!ee,8 ,;ffffcf,"8 ,;ffffc,,28 ,;ffff121"8 ,;ffffa5#f8 ,;ffff+a#58,;ffff+12%8 ,;ffff%+c18 ,;ffff%45f8 ,;ffff%1118 ,;ffff%,,28 ,;ffff%1118 ,;ffff%45f8 ,;ffff%+c18,;ffff+12%8 ,;ffff+a#"8 ,;ffffa5#f8 ,;ffff121"8 ,;ffffc,,28 ,;ffffcf,"8 ,;ffff!ee,8 ,;ffffef4cSA ($6"#13\IC23\Config config B R i ,;,,1#8 2C , ($6"#13\IC23\L:)*I&VIL Left line input channel volume C2 ,;,,1#8 2C 1 ($6"#13\IC23\-IT7*I&VIL -ight line input channel volume C2 ,;,,!%8 2C 2 ($6"#13\IC23\L:)*74VIL Left channel hea!phone volume C2 ,;,,!%8 2C 3 ($6"#13\IC23\-IT7*74VIL -ight channel hea!phone volume C2 ,;,,118 2C 4 ($6"#13\IC23\&4*7 nalog au!io path control C2 ,;,,,,8 2C 5 ($6"#13\IC23\(IT4*7 (igital au!io path control C2 ,;,,,,8 2C " ($6"#13\IC23\4I>:-(I>& 4ower !own control C2 ,;,,438 2C # ($6"#13\IC23\(ITI) (igital au!io interface format C2 ,;,,%c8 2C % ($6"#13\IC23\$34L:-*: $ample rate control C2 ,;,,,1 2C + ($6"#13\IC23\(ITC* (igital interface activation C2 SA ($6"#13\IC23\Co!ec7an!le hCo!ecA Int32 Init>ait B1A Int32 !ataA float in\1ufferJ1,,KA float In$igWufferJ",,KA float &oiseWufferJ",,KA float Corr$igWufferJ",,KA 118 float -ecov$igWufferJ",,KA int LogIn!e; B,A main/0R int iA L:(B,;,A for/ i B , A i Y 1,,A iDD 0 in\1ufferJiKB,.,A hCo!ec B ($6"#13\IC23\openCo!ec/,8 lconfig0A I-n\glo1al:na1le/0A I-n\ena1le/I-n\:V*\-I&*10A I-n\ena1le/I-n\:V*\UI&*10A S voi! le!/0R static int cc B 1A L:( B ccA if /cc BB ,;,30 cc B ,;,5A else if /cc BB ,;,50 cc B ,;,"A else if /cc BB ,;,"0 cc B ,;,3A else cc B ,;,3A S setpll2,,3/0R S voi! rea!/0R int i B ,A float resultA float In(ataA float In&oiseA float InCorrupA static int &oiseIn!e;B,A static int $inIn!e; B ,A !ataB3CW$4\rea!/($6"#13\IC23\(*7&(L:0A if/!ata=B32#"%0 !ataB !atac,;ffff,,,,A 22 Comment from here In(ata B /float0 /sineta1leJ$inIn!e;K021"A $inIn!e; DB 4A if /$inIn!e; =B 4%0 $inIn!e; @B4%A 22 Comment till here In&oise B 4r&oiseJ&oiseIn!e;DDKC4,+" ' 1,24A if /&oiseIn!e; BB ",,0 &oiseIn!e; B ,A 119 InCorrup B In(ata D In&oiseA for/ i B ,A i YB /)iltLen'20A iDD0 in\1ufferJiK B in\1ufferJiD1KA in\1ufferJ)iltLen'1KBInCorrupA result B ,A for/ i B , A i YB /)iltLen'10A iDD 0 result DB -em&oiseJiK C in\1ufferJiKA !ata B /Int320/resultC5120A 22 )or (emo In$igWufferJLogIn!e;KB In(ataA &oiseWufferJLogIn!e;KB In&oise A Corr$igWufferJLogIn!e;KB InCorrupA -ecov$igWufferJLogIn!e;K B /float0!ataA LogIn!e;DDA if /LogIn!e; BB ",,0 LogIn!e; B,A S voi! write/0R if /Init>aitY1,,,0R Init>aitDDA 3CW$4\write/($6"#13\IC23\(*7&(L:8 ,0A 3CW$4\write/($6"#13\IC23\(*7&(L:8 ,0A S elseR 3CW$4\write/($6"#13\IC23\(*7&(L:8 !ata0A 3CW$4\write/($6"#13\IC23\(*7&(L:8 !ata0A S S Iutput5 120 4. :nter the source co!e an! save the file with main.c e;tension. 5. -ight clicG on source8 $elect a!! files to pro]ect an! Choose main.c file $ave! 1efore. 121 ". !! the other supporting .c files which configure the au!io co!ec. #. #. a0 To to 4ro]ect to Compile. 10 To to 4ro]ect to Wuil!. c0 To to 4ro]ect to -e1uil! ll. 122 %. To to file an! loa! program an! loa! B.$(!A file into the 1oar!. 123 It will shows warnings an! errors if any +. To to (e1ug an! clicG on run to run the program. 124 1,. *o see the Traph go to View an! select time2frequency in the Traph an! give the correct $tart a!!ress provi!e! in the program8 (isplay !ata can 1e taGen as per user. 11. Treen line is to choose the point8 Value at the point can 1e seen /7ighlighte! 1y circle at the left corner0. 125 E,p#%im#n! 9: Imp(l)# R#)p$n)# P%$0#/(%# !$ 0%#a!# n#7 P%$?#0!: 1. *o create pro]ect8 To to 4ro]ect an! $elect &ew. 2. Tive pro]ect name an! clicG on finish. / N$!#: Location must 1e c5iCC$tu!io\v3.1i3y4ro]ects 0. 126 3. ClicG on )ile &ew $ource )ile8 *o write the $ource Co!e.
AIM: *o fin! Impulse response of a first or!er an! secon! or!er system. 127 !iscrete time system performs an operation on an input signal 1ase! on pre!efine! criteria to pro!uce a mo!ifie! output signal. *he input signal ;/n0 is the system e;citation8 an! y/n0 is the system response. *he transform operation is shown as8
;/n0 y/n0 B *J/;/n0K *he convolution sum can 1e represente! 1y8 y/n0 B ;/n0 C h/n0 F$% E,ampl# l#!-) .in/ $(! an imp(l)# %#)p$n)# $. a /i..#%#n0# #'(a!i$n. *he general form of !ifference equation is8 3 3 y/n0 B Na G y/n'G0 D N1 G ;/n'G0 GB1 GB, Find out the impulse response of second order difference equation. P%$%am: jinclu!eYst!io.h= j!efine Ir!er 2 j!efine Len 5 float hJLenK B R,.,8,.,8,.,8,.,8,.,S8sumA voi! main/0 R int ]8 GA float aJIr!erD1K B R,.13118 ,.2"228 ,.1311SA float 1JIr!erD1K B R18 ',.#4#%8 ,.2#22SA for/]B,A ]YLenA ]DD0 R sum B ,.,A for/GB1A GYBIr!erA GDD0 R if //]'G0 =B ,0 sum B sumD/1JGKChJ]'GK0A S if /] YB Ir!er0 hJ]K B aJ]K'sumA else hJ]K B 'sumA printf /k @f k8hJ]K0A 128
* S S O(!p(!: ,.1311,, ,.3",23# ,.3"4#++ ,.1#4#41 ,.,313#3 For first order difference equation. P%$%am: jinclu!eYst!io.h= j!efine Ir!er 1 j!efine Len 5 float hJLenK B R,.,8,.,8,.,8,.,8,.,S8sumA voi! main/0 R int ]8 GA float aJIr!erD1K B R,.13118 ,.2"22SA float 1JIr!erD1K B R18 ',.#4#%SA for/]B,A ]YLenA ]DD0 R sum B ,.,A for/GB1A GYBIr!erA GDD0 R if//]'G0=B,0 sum B sumD/1JGKChJ]'GK0A S if/]YBIr!er0 hJ]K B aJ]K'sumA else hJ]K B 'sumA printf/k@f k8 ]8 hJ]K0A S S O(!p(!: ,.1311,, ,.3",23# ,.2"+3%5 ,.2,144" ,.15,"41 4. :nter the source co!e an! save the file with 9 .CA e;tension. 129 5. -ight clicG on source8 $elect a!! files to pro]ect .. an! Choose 9.C 9 file $ave! 1efore. 130 ". -ight ClicG on li1raries an! select a!! files to 4ro]ect.. an! choose C5iCC$tu!io\v3.1iC",,,icgtoolsili1irts"#,,.li1 an! clicG open. 131 #. a0 To to 4ro]ect to Compile. 10 To to 4ro]ect to Wuil!. 132 c0 To to 4ro]ect to -e1uil! ll. %. To to file an! loa! program an! loa! B.$(!A file into the 1oar!.. 133 It shows errors an! warnings here. +. To to (e1ug an! clicG on run to run the program. 134 1,. I1serve the output in output win!ow. 135 136 Iutput will !isplay here 11. *o see the Traph go to View an! select time2frequency in the Traph8 an! give the correct $tart a!!ress or the output varia1le name provi!e! in the program8 (isplay !ata can 1e taGen as per user. $elect ($4 !ata type as 32'1it floating point. 137 12. Treen line is to choose the point8 Value at the point can 1e seen /7ighlighte! 1y circle at the left corner0. 138