Experiment No. 1 Discretization of signals : Sampling and ... · A. Theory 1) J. Proakis and D....

19
1 Experiment No. # 1 Discretization of signals : Sampling and Reconstruction 1) Objectives: a) Signal Sampling and Reconstruction. b) Introduction to simulink. 2) Software used: a) MATLAB. A. Pre-Lab a) Read about analog to digital conversion. b) Go through matlab inbuilt funcion. sin(), interp1(), length(), ceil() I. S AMPLING AND RECONSTRUCTION A. Theory 1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications B. Procedure 1) Generate a sinusoidal signal, x(t)= A cos(2πft) of frequency 3000 Hz and 1Vpp for four complete cycles.(How do you generate an analoge signal in MATLAB? if no, then what will be the other alternative?) Take F s =1, 00, 000 Hz for ideal signal. 2) The discrete time sampled signal is given by replacing t with nT s x(nT s)= A cos(2πfnTs) (1) where n is sample number and Ts is time period of signal having frequency Fs. 3) Generate sampled signal, y(t), after sampling x(t) with sampling frequency Fs 1 = 10000Hz. 4) Repeat 2 and 3 for different sampling frequencies Fs 2 = 6000 Hz, Fs 3 = 12000 Hz, Fs 4 = 4000 Hz, Fs 5 = 5000 Hz. Is there aliasing ?

Transcript of Experiment No. 1 Discretization of signals : Sampling and ... · A. Theory 1) J. Proakis and D....

Page 1: Experiment No. 1 Discretization of signals : Sampling and ... · A. Theory 1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications B. Procedure

1

Experiment No. # 1Discretization of signals : Sampling and Reconstruction

1) Objectives:a) Signal Sampling and Reconstruction.b) Introduction to simulink.

2) Software used:a) MATLAB.

A. Pre-Laba) Read about analog to digital conversion.b) Go through matlab inbuilt funcion.

sin(), interp1(), length(), ceil()

I. SAMPLING AND RECONSTRUCTION

A. Theory1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications

B. Procedure1) Generate a sinusoidal signal,

x(t) = A cos(2πft)

of frequency 3000 Hz and 1Vpp for four complete cycles.(How do you generate an analoge signalin MATLAB? if no, then what will be the other alternative?) Take Fs = 1, 00, 000 Hz for ideal signal.

2) The discrete time sampled signal is given by replacing t with nTs

x(nTs) = A cos(2πfnTs) (1)

where n is sample number and Ts is time period of signal having frequency Fs.

3) Generate sampled signal, y(t), after sampling x(t) with sampling frequency Fs1 = 10000Hz.

4) Repeat 2 and 3 for different sampling frequencies Fs2 = 6000 Hz, Fs3 = 12000 Hz, Fs4 = 4000Hz, Fs5 = 5000 Hz. Is there aliasing ?

Page 2: Experiment No. 1 Discretization of signals : Sampling and ... · A. Theory 1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications B. Procedure

2

5) Plot the spectrum of the above generated waves using fourier transform or inbuilt FFT funcion andidentify aliased frequencies.

6) For reconstruction of sampled signal pass y(t) through an interpolator and generate reconstructedsignal z(t) either writing linear interpoltion code or using inbuilt function interep1().

7) Calculate Mean square error(MSE) between x(t) and z(t). What should be the maximum andminimum value of MSE for different sampling frequencies.

8) Calculate MSE for different interpolation techniques.

9) Observation:a) Plot 5 cycles of input signal for different sampling frequencies.b) Plot Fourier spectrum and determine the aliasing effect.c) Find the MSE for linear interpolation with different sampling rates (Plot MSE Vs Fs).d) Repeat MSE VS Fs for different interpolation techniques.e) Perform sampling and Interpolation in simulink.

10) Conclusion:a) Use different sampling rates and conclude MSE observation?b) Use different types of interpolation(linear, spline, cubic spline) and conclude which one is the

best?

II. INTRODUCING SIMULINK

1) Open simulink and create a model file with .slx extension.

2) Find various sources(sinewave, binary sequence, random sequence) and sinks(display, constellationdiagram, to workspace) etc.

3) Drag the various functions to model file.

4) Search for matlab function in simulink blockset.

5) Repeat all the ’Procedure’ steps and recreate the sampling of discrete signal into simulink.

Well Done

Page 3: Experiment No. 1 Discretization of signals : Sampling and ... · A. Theory 1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications B. Procedure

1

Experiment No. # 2Discretization of signals : Quantization and Encoding

———————————————————————————————————————————

1) Objectives:a) Quantization and Encoding.b) Simulink based Quantization.

2) Software used:a) MATLAB.

A. Pre-Laba) Read about analog to digital conversion.b) practice simulink.

I. QUANTIZATION

A. Theory1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications

B. Procedure1) Generate a sinusoidal signal,

x(t) = A cos(2πft)

of frequency 3000 Hz and 1Vpp for four complete cycles with sampling rate 100000 Hz.

2) The discrete time sampled signal is given by replacing t with nTs

x(nTs) = A cos(2πfnTs) (1)

where n is sample number and Ts is time period of signal having frequency Fs.

3) Generate sampled signal, y(t), with message signal frequency F = 3000 Hz and sampling frequencyFs = 8000Hz.

4) Make your own function myquantizer(y,L) for following quantizer specification.• Type of Quantizer - Uniform.• Input Range of Quantizer - 1Vpp.• Levels of Quantizer - L.

Page 4: Experiment No. 1 Discretization of signals : Sampling and ... · A. Theory 1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications B. Procedure

2

5) Generate quantized signal g(t) by quantizing y(t) for different quantizer levels ’L’ i.e. 8, 16, 32, 64etc.

6) Compute Mean Square error between g(t) and y(t) i.e. quantization noise power(Qe) and verify itwith the theoretical expression for SQNR of sinusoidal signal given by

SQNR =3

2(22b)

= 1.76 + 6.02(b) (In dB)

where b is the no. of bits representing a particular level (i.e.Total levels L = 2b).

7) Now, Fix the number of quantization level L to 64 and change peak to peak amplitude of inputsignal x(t) from 0.1Vpp to 1Vpp with the difference of 0.1Vpp. Compute Signal to quantizationnoise ratio(SQNR) for all cases.

8) Encoding:Obtain quantized signal and represent each level by a definite binary number. The number of digitsb >= log(L).

9) Observation:a) Plot 5 cycles of sampled signal and quanitized signal for various values of L = 8.b) Plot the graph between quantization noise power(Qe) and quantization level L= 16, 32, 64.c) Plot SQNR vs input voltage for various voltage levels as given in step.d) Plot the sampled, quantized and encoded signal of a single complete cycle for L = 8.e) Repeat the experiment in simulink.

10) Conclusion: Conclude the effect of increasing quantization level on SQNR. Also mention effect ofsignal amplitude on SQNR.

II. QUANTIZATION IN SIMULINK

1) Open simulink and create a model file with .slx extension.

2) Find various sources(sinewave, Quantizer) and sinks(display, scope) etc.

3) Drag the various functions to model file.

4) Search for matlab function in simulink blockset.

5) Repeat all the ’Procedure’ steps and recreate the Quantization and Encoding of discrete signal intosimulink.

Well Done

Page 5: Experiment No. 1 Discretization of signals : Sampling and ... · A. Theory 1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications B. Procedure

1

Experiment No. # 3Discretization of signals : LTI system characterization

1) Objectives:a) Linear convolution and DFT Matrix generation.b) Simulink based convolution.

2) Software used:a) MATLAB.

A. Pre-Laba) Read about LTI system characterization.b) practice simulink.

I. CONVOLUTION AND DFTA. Theory

1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications

B. Procedure1) Linear Convolution: Write a MATLAB function myLinConvMat.m that takes in the impulse response

h(n) of an LSI system and the length of input sequence x(n) and provides in output ’the matrix’representing the convolution operator H. Compute and plot the convolution results for each of thefollowing hi(n), i = 1, 2, 3, 4.

h1(n) = {1, 1}

h2(n) = {1,−1}

h3(n) =1

3{1, 1, 1}

h4(n) =1

4{1, 1, −4, 1, 1}

xi(n) = cos(2fin) {wherefi = 0,1

10,1

5,1

4,1

2}

Here n = 0, 1, · · · 999 samples.The concolution sum is given by

y(n) =L−1∑i=0

h(i)x(n− i)

where L is length of impulse response hi(n).

Page 6: Experiment No. 1 Discretization of signals : Sampling and ... · A. Theory 1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications B. Procedure

2

2) DFT: Write a MATLAB function myDft.m that takes in a finite length sequence and produces theDiscrete Fourier Transform of the input.

X(k) =N−1∑n=0

x(n)ej2πnkN

Where k = 0, 1, · · ·N − 1 and N = 8, 16, 64 no.of points. Compare your results for hi(n)’s (ofExercise1) with 8, 16, 32, 64 point fft output. The fft is a fast way of computing DFT and is availablein MATLAB.

3) Observation:a) Generate Convolution matrix H.b) Perform linear convolution code and compare your results with MATLAB built in command

for linear convolution.c) Genrate DFT matrix using expresion for various no. of points (8, 16, 32)etc.d) Utilize the DFT matrix (8, 16)points to find DFT of any given sequence and compare the

results with inbuilt fft sequence.e) Repeat the experiment in simulink.

4) Conclusion: Conclude the experiment.

II. CONVOLUTION IN SIMULINK

1) Open simulink and create a model file with .slx extension.

2) Read input data through any random binary source.

3) Take channel coefficents h = 1, 0.5, 0.25.

4) Perform the convolution using matlab function in simulink.

5) Repeat all the ’Procedure’ steps and recreate all functional blocks into simulink.

Well Done

Page 7: Experiment No. 1 Discretization of signals : Sampling and ... · A. Theory 1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications B. Procedure

1

Experiment No. # 4LTI System Characterization II: Circular convolution and DFT makes Fourier

Transform pair

1) Objectives:a) Circular convolution and DFT Multiplication for two sequences.b) Simulink based circular convolution.

2) Software used:a) MATLAB.

A. Pre-Laba) Read about circular convolution.b) practice simulink.

I. CIRCULAR CONVOLUTION⇔ DFTA. Theory

1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications

B. Procedure1) Circular Convolution: Write a MATLAB function myCirConvMat.m that takes in the impulse

response h(n) of an LSI system and the length of input sequence x(n) and provides in outputthe matrix representing the circular convolution operator H . Compute and plot the convolutionresults for the following:

h1(n) = {2, 1, 2, 1}

x1(n) = {1, 2, 3, 4}

x2(n) = 0.5n

Here n = 0, 1, · · · 9 samples.The circular concolution sum for a system with h(n) system response and x(n) input is given by (both paded with zeros to make the length equal of both the sequences).

y(n) =N−1∑i=0

h(i) · x((n− i))N

Where N , the sequence length is greater or equal to length of the larger sequence and taken asmultiple of 2. N = 2i i = 2, 3, 4....Also, x((n− i))N represents the index ’((n− i) modulo N ) = N − i+ n’.

Page 8: Experiment No. 1 Discretization of signals : Sampling and ... · A. Theory 1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications B. Procedure

2

2) Change of basis: For an LSI system, let the impulse response be given by h(n) = h(0), · · ·h(7).The 8-point input to this system is a finite duration sequence x(n) = x(0) · · · x(7).Now, to verify Circular Convolution ⇔ DFT, perform the following steps.

a) Use your myCirConvMat.m to find circular convolution of h(n) and x(n) given by y(n).b) Use myDFT function to generate 8-Point DFT matrix.c) Find out 8-point DFT of sequence h(n) and x(n) given by H(k) and X(k).d) Multiply both above DFT sequence point by point and generate Y (k) = H(k) ·X(k).e) Find inverse DFT od Y (k) using myDFT function and compare the result with the first step.

Let’s verify it using matrix multiplication.a) Use your myCirConvMat.m to find convolution matrix H.b) Use myDFT function to generate 8-Point DFT matrix D8.c) Find out 8-point DFT of sequencex(n) given by XF (k).d) Calculate HF = D8 · H · D−1

8 . Is this matrix Diagonal? Compute YF = HF · XF . Findy = D−1

8 · YF

e) Compare the above result with the circular convolution of h(n) and x(n).

3) Observation:a) Generate Circular Convolution matrix H.b) Perform circular convolution code and compare your results with MATLAB built in command

for circular convolution.c) Generate myIDFT using myDFT function. Verify ’Circular convolution ⇔ DFT multiplication

are fourier transform pair’ using first five steps of change of basis section.d) Verify the above answers using the matrix multiplication steps given in the change of basis

section.e) Repeat the experiment in simulink.

4) Conclusion: Conclude the experiment.

II. CONVOLUTION IN SIMULINK

1) Open simulink and create a model file with .slx extension.

2) Read input data x = [1, 2, 3, 4] through command window.

3) Take channel coefficents h = [2, 1, 2, 1].

4) Perform the circular convolution using matlab function in simulink.

5) Repeat all the ’Procedure’ steps and recreate all functional blocks into simulink.

Well Done

Page 9: Experiment No. 1 Discretization of signals : Sampling and ... · A. Theory 1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications B. Procedure

1

Experiment No. # 5Linear convolution using ZYBO Evaluation Board

1) Objectives:a) Linear Convolution of two sequences on ZYBO (FPGA) Evaluation Board.

2) Software used:a) Vivado.

A. Pre-Laba) Read basic VHDL or verilog coding.b) Read specification sheet or pin diagram of ZYBO board.c) Perform Half-Adder and Clock divider on the vivado software prior to the lab.

I. LINEAR CONVOLUTION USING ZYBO EVALUATION BOARD

A. Theory:1) ”Introduction to VHDL”, J.Bhaskar.

B. Procedure:1) Linear Convolution: On ZYBO board, As a first step to visualize the convolution we have following

things available,• 4 Pushbutton switches• 4 DIP switches• 4 LEDs• Internal clock of (450 MHz), so multiply with a very high integer value approx. ’5000000’, to

make the LED visually stabel for second.2) Open Vivado software.3) Follow all the basic steps to create a linearconvol.pjt project.4) Create/Add a VHDL RTL linearconvol.vhd file with A and B as inputs and C as output having 4

digits (3 downto 0).5) Create a constraint file, in which copy the standard ZYBO pin constraint file available on Internet

or shared with you.6) Uncomment the DIP swithches, pushbutton switches and LEDs required and map to the variables

created in the vhdl source file.7) Follow all the steps to perform analysis and synthesize the above project (Simply follow all the

next next steps in vivado till the synthesis is done successfully).8) Utilize vivado system simulator to simulate the linear convolution.9) Again follow the internal steps of vivado to generate bit stream.

10) Open Hardware manager, add the zybo board available and change the system clock to minimumvalue.

11) Program the device using generated bit stream.

Page 10: Experiment No. 1 Discretization of signals : Sampling and ... · A. Theory 1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications B. Procedure

2

C. Observation:1) Perform an LED ON and OFF using DIP switch.2) Perform an LED ON-OFF using Pushbutton switch.3) Change the LED ON-OFF speed by controlling the internal clock.4) Verify linear convolution in simulator.5) Verify linear convolution of two sequences having 4 bit length on LEDs using DIP and push-button

switches.

D. Conclusion:Conclude the experiment.

Well Done

Page 11: Experiment No. 1 Discretization of signals : Sampling and ... · A. Theory 1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications B. Procedure

1

Experiment No. # 6Transform Based Lossy Compression

1) Objectives:a) Discrete Cosine Transform and it’s energy compaction property.b) Simulink based image compression.

2) Software used:a) MATLAB.

A. Pre-Laba) Read about Discrete Cosine tranform and image compression.b) practice simulink.

I. DISCRETE COSINE TRANSFORM (DCT)A. Theory

1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications

B. Procedure1) Discrete Cosine Transform: Write a MATLAB code myCompression.m that takes in the image,

find the DCT, store the significant transform domain coefficients and discards the nonsignificantcoefficients, thus compress the original image in a compact form. Reconstruction of the image isdone by following all the steps of compression in reverse manner.

2) Let Im1 be the gray-scale image of size N ×N . The corresponding 2D-Discrete Cosine TransfromImF1 is given by

ImF1(k; l) =1√2N

β(k)β(l)N−1∑i=0

N−1∑j=0

Im1(i, j) cos

(π(2j + 1)k

2N

)cos

(π(2i+ 1)l

2N

)where

β(u) =1√2, u = 0

= 1, u > 0

a) Use the above expression and write down the expression for 2D-DCT with N = 8.b) Divide the image for ex. ’cameraman.bmp’ into non-overlapping blocks of size 8×8. For each

of them compute the 2D-DCT.c) Now starting from the bottom-left corner of each block that is obtained from 2D-DCT, knock-

off the coeffcients gradually one by one, or in other words neglect the higher frequency terms,and for each removal of coefficient reconstruct an approximation to the original 8× 8 image

Page 12: Experiment No. 1 Discretization of signals : Sampling and ... · A. Theory 1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications B. Procedure

2

block via 2D-IDCT. Put together all the blocks and the approximation to the original image.(apply zig-zag pattern to scan the image)

d) Perform the above procedure for four cases.Case 1: Keep top 48 coefficients out of 64.Case 2: Keep top 32 coefficients out of 64.Case 3: Keep top 16 coefficients out of 64.Case 4: Keep top 8 coefficients out of 64.

e) Calculate the mean square error ε = |Im1−Im1|2, where Im1 is a reconstructed approximation.

f) Plot the graph of Mean Squared Error ε versus Compression Ratio ρ. Where

ρ =N2 − Total No. of knocked off coefficents

N2

3) Observation:a) Use inbuilt DCT and IDCT function to compress and reconstruct any input image. Also by

knocking off half the pixels of compresed image show the image artifact effects(at edges/bordersin the image).

b) Write down the myCompression.m function using the expression and cross verify with theinbuilt DCT function.

c) Divide the whole image in 8× 8 blocks use above function to compress the whole image withtop 32 coefficents and find the mse. (Is artifact still visible ?)

d) Repeat he above steps for given four different cases and plot the graph between mse andcompression ratio.

e) Repeat the experiment in simulink.4) Conclusion: Conclude the experiment.

II. CONVOLUTION IN SIMULINK

1) Open simulink and create a model file with .slx extension.

2) Transfer the image data from command window to the above generated model file.

3) Write down or utilize myCompression.m. in model file to compress and reconstruct the image.

4) Write a generalized model which takes dividing block size(for ex. 4,8,16), Total no. of knock offcoefficents(for ex. Top 16, 32, 48) and perform compression.

Well Done

Page 13: Experiment No. 1 Discretization of signals : Sampling and ... · A. Theory 1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications B. Procedure

1

Experiment No. # 7Discrete Cosine Transform Based Audio Compression

1) Objectives:a) Discrete Cosine Transform and it’s energy compaction property.b) Simulink based Audio compression.

2) Software used:a) MATLAB.

A. Pre-Laba) Read about Discrete Cosine tranform and compression.b) practice simulink.

I. DISCRETE COSINE TRANSFORM (DCT)A. Theory

1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications

B. Procedure1) Discrete Cosine Transform: Write a MATLAB code myCompression.m that takes the audio file

as the input, find the one dimension DCT, store the significant transform domain coefficients anddiscards the nonsignificant coefficients, thus compress the original audio file in a compact form.Reconstruction of the audio file is done by following all the steps of compression in reverse manner.

2) Steps :a) Let x be the audio file of size 1×N . The corresponding 1D-Discrete Cosine Transfrom y is

given by

y(k) = w(k)N∑

n=1

x(n) cos

(π(2n− 1)(k − 1)

2N

)where

w(k) =1√N, k = 1

=

√2

N, k > 1

Also n = 1, 2, · · ·N .

b) Use the above expression and write down the function for 1D-DCT for N = 8, 16, ...256.c) Divide the audio data into non-overlapping blocks of size 1× 256. For each of them compute

the 1D-DCT.

Page 14: Experiment No. 1 Discretization of signals : Sampling and ... · A. Theory 1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications B. Procedure

2

d) Now define two threshold value , Let’s sayThresold1 = 0.09Thresold2 = −0.09Keep the DCT coefficents available from above step whose value is greater than Thresold1and less than Thresold2.

e) Take the 1D-IDCT usingf)

xidc(n) =N∑k=1

w(k)y(k) cos

(π(2n− 1)(k − 1)

2N

)where

w(k) =1√N, k = 1

=

√2

N, k > 1

Also n = 1, 2, · · ·N .

g) Repeat the above procedure for below cases.Case 1: Thresold1 = 0.5Thresold2 = −0.5Case 2: Thresold1 = 0.01Thresold2 = −0.01

h) Calculate the mean square error ε = |x− xidc|2, where xidc is a reconstructed approximation.i) Calculate compression ratio for all cases.

3) Observation:a) Use inbuilt DCT and IDCT function to compress and reconstruct any audio file.b) Write down the myCompression.m and myDeCompression.m function using the expressions

given and cross verify with the inbuilt DCT-IDCT function.c) Divide the whole audio file in nonoverlapping blocks of size 1× 256. Use above function to

compress the whole audio file with coefficents saved according to the thresold values. Use my-DeCompression.m function to reconstruct audio file, and write in ”‘outputcompression.wav”’file.

d) Repeat the above steps for given different thresold cases and make a table for mse andcompression ratio for given thresold values.

e) Repeat the experiment in simulink.f) Conclusion: Conclude the experiment.

II. COMPRESSION IN SIMULINK

a) Open simulink and create a model file with .slx extension.b) Transfer the audio data from command window to the above generated model file.c) Write down or utilize myCompression.m in model file to compress and reconstruct the Audio.d) Write a generalized model which takes thresold value as argument and and perform compres-

sion and reconstruction.

Well Done

Page 15: Experiment No. 1 Discretization of signals : Sampling and ... · A. Theory 1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications B. Procedure

1

Experiment No. # 08Radix-2 FFT Algorithm and complexity reduction

———————————————————————————————————————————

1) Aim:a) Radix-2 FFT Algorithm.

2) Software used:a) MATLAB.

3) Theorya) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications,

ser. Prentice-Hall International editions. Prentice Hall, 1996. [Online]. Available:http://books.google.co.in/books?id=sAcfAQAAIAAJ

4) Procedure FFT Algorithm:Desimation in timeThe N-point Discrete fourier transform(DFT) calculation generally requires N2 complex multiplica-tions.(Think of N = 1024). On the other hand Radix-2 FFT algorithm: Desimation in time(DIT) orDecimation in frequency(DIF) are computationally efficient and requires only N

2· log2N complex

multiplications.a) Let’s consider a sequence x[n] of length N and calculate it’s N point DFT.(For Simplicity

N = 2V , V is an integer)

b) The N length sequence can be divided into two N/2 point data sequence f1[n] and f2[n],corresponding to the even numbered and odd numbered samples of x[n] as shown in next step.

c) The DFT of x[n] is given by

X[k] =N−1∑n=0

x[n] ·W knN (1)

where k = 0,1,2, ... N2

-1 and WN = exp(−j ∗ 2 ∗ pi/N).

d) Breaking x[n] into even and odd sequence

X[k] =∑

n=even

x[n] ·W knN +

∑n=odd

x[n] ·W knN

X[k] =

N2−1∑

m=0

x[2m] ·W 2mkN +

N2−1∑

m=0

x[2m+ 1] ·W (2m+1)kN

Page 16: Experiment No. 1 Discretization of signals : Sampling and ... · A. Theory 1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications B. Procedure

2

e) This leads to

X[k] =

N2−1∑

m=0

f1[m] ·WmkN/2 +

N2−1∑

m=0

f2[m] ·WmkN/2

since W 2N = WN/2.

X[k] = F1[k] + F2[k] ·W kN (2)

for k = 0,1,2....N-1, where F1[k] and F2[k] are N/2 point DFT sequence of f1[m] and f2[m]

f) Also by using periodicity of F1[k] and F2[k] (means Fi[k+N2] = Fi[k] for i = 1, 2), the above

equation reduces toX[k] = F1[k] + F2[k] ·W k

N (3)

X[k] = F1[k]− F2[k] ·W kN (4)

for k = 0,1,2,...N2− 1.

g) The above expression shows that direct computation of F1[k] requires N2

2 complex multipli-cations, same for F2(k). Additional N

2for F2[k] ·W k

N . Thus calculating N point DFT of x[n]using above method total requires Total = (N

2)2 + (N

2)2 + N

2complex multiplication.

h) At the same time, Note that the direct calculation of N point DFT of x[n] as per eq.(1) requirestotal N2 complex multiplications. So reduction in Total = N2 − ((N

2)2 + (N

2)2 + N

2)

i) Again, split f1[n] and f2[n] sequence into even and odd sequence and do all the above stepsagain.

j) Re-do all the above steps untill the final sequence has only one point sequence. At this pointthe total complex multiplications requeired for N point DFT using Direct method is N2 andusing above stpes is N

2· log2N .

k) For refrence, an N=8 point Radix-2 FFT algorithm is given in Fig.1. on next page.

5) Observation:a) Simulate N = 2 point fft using above method, and verify the answer with inbuilt fft() function

for input sequence x[n] of length 2 or more.

b) Simulate N = 4 point fft using above method, and verify the answer with inbuilt fft() functionfor input sequence x[n] of length 4 or more.

c) Simulate N = 8 point fft using above method, and verify the answer with inbuilt fft() functionfor any arbitrary N length sequence x[n].

d) Plot speed factor Vs N, for various N = 2,4,8,16,128 values. Speed factor is given by

Speed factor =Complex multiplications in Direct-method

Complex multiplications in Radix-2 FFT method

e) Repeat the experiment in simulink.6) Conclusion: Conclude the experiment.

Page 17: Experiment No. 1 Discretization of signals : Sampling and ... · A. Theory 1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications B. Procedure

3

Fig. 1. Radix-2 N=8-point FFT

Well Done

Page 18: Experiment No. 1 Discretization of signals : Sampling and ... · A. Theory 1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications B. Procedure

1

Experiment No. # 9Digital Filter Design: Windowing, Linear phase FIR

———————————————————————————————————————————

1) Aim:a) Digital Filter Design.

2) Software used:a) MATLAB.

3) Theorya) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications

4) Procedurea) Windowing Based design: Rectangle, Hamming, Blackman

i) Let’s consider a low pass filter, whose response is given by

Hd(w) = e(−j·w·(M−1

2 )) · · · , 0 ≤ |w| ≤ wc (1)

Hd(w) = 0, · · ·Otherwise.

where M is corresponding delay in time domain.ii) The corresponding filter impulse response can be found by

hd(n) =1

∫ wc

−wc

e(−j·w·(n−M−1

2 ))dw (2)

and is given by

hd(n) =sin(wc(n−

(M−12

)))(π(n−

(M−12

))) (3)

iii) This impulse response is windowed using the windows mentioned below.A) Rectangle Window: w(n) = 1B) Hamming Window: w(n) = 0.42− 0.5 · cos( 2πn

M−1) + 0.08 · cos( 4πn

M−1)

C) Blackman Window: w(n) = 0.54− 0.46 · cos( 2πnM−1

)where n = 0, 1, · · ·M − 1

iv) The finite impulse response h(n) is then windowed impulse response given by

h(n) = hd(n) · w(n) (4)

where n = 0,1,2, ... M − 1.

Page 19: Experiment No. 1 Discretization of signals : Sampling and ... · A. Theory 1) J. Proakis and D. Manolakis, Digital signal processing: principles, algorithms, and applications B. Procedure

2

b) Filtering Hamming sound using filtering:i) Let’s read an audio file and sample it using 32 Khz. Let’s also consider this audio file has

a hamming sound or Hiss having frequency greater than (π2) 8 KHz. Follow the steps and

remove the hissing sound.ii) Steps:

• Take 256 samples of the audio file and locate the hissing frequency (Approximately at66th and 192th sample).

• Use the low pass filter designed in previous exercise, having cut off frequency π2

i.e (orideal filter having ones for first 64 samples and zeros for next 64 sample over a span of0 to π frequency).

• Multiply the filter response and spectrum of audio signal for N= 256 samples.• Repeat above step for the whole audio file.• Check whether hiss sound removed and also conclude for distortion audible if any.

c) Notch Filtering of Hiss:i) Let’s read an audio file and sample it using 32 Khz. Let’s also consider this audio file has

a hissing sound at 8 KHz. Follow the steps and remove the hissing sound.ii) Steps:

• Take 8 samples of the audio file and locate the hissing frequency (Approximately at 3rd

and 7th sample).• Design a notch filter at frequency π

4i.e (By placing complex conjugate pairs of zeros at

±π4

frequency).• Convolve the impulse response h(n) with the distorted file Or Multiply the filter responseH(w)( Having zero values at corresponding frequencies) and spectrum of audio signalfor N = 8 samples. Here the transfer function H(w) and the impulse response h(n)having complex conjugate zeros at frequencies π

4is given by

H(Z) = (1− exp(j · π4)Z−1)(1− exp(−j · π

4)Z−1) = 1− 2 cos(

π

4)Z−1 + Z−2 (5)

h(n) = [1,−2 cos(π4), 1] (6)

• Check whether hiss sound removed and also conclude for distortion audible if any.5) Tasks and Observations:

a) Window Based Filtering: Use Eq.(1),(2),(3),(4)i) Simulate vaious window(rectangle, hamming, blackman’s) based Low pass FIR filter with

cutoff frequncies wc = π2, π4, π6, show the frequncy response of the windowing functions

and plot the magnitude(in dB), phase response of the designed FIR filter.ii) Simulate vaious window(rectangle, hamming, blackman’s) based High pass FIR filter with

cutoff frequncies wc = π2, π4, π6, show the frequncy response of the windowing functions

and plot the magnitude, phase response of the designed FIR filter.iii) Simulate vaious window(rectangle, hamming, blackman’s) based band pass FIR filter with

cutoff frequncies wc(low) = π4, wc(high) = π

2, show the frequncy response of the window-

ing functions and plot the magnitude, phase response of the designed FIR filter.b) Remove the hissing sound using above generated filter.c) Remove the hissing sound using Notch filter.d) Repeat the experiment in simulink.

6) Plot all the signals in all of the above steps and justify them.7) Conclusion Write/plot your own.