digital signal processing manual

92
Digital Signal Processing Lab Manual DIGITAL SIGNAL PROCESSING LAB MANUAL III YEAR II SEMESTER (ECE) Presented by: Dep of ECE 1 BEC

Upload: mallesh-malli

Post on 27-Sep-2015

15 views

Category:

Documents


3 download

DESCRIPTION

programs for DSP

TRANSCRIPT

Digital Signal Processing Lab Manual

DIGITAL SIGNAL PROCESSINGLAB MANUAL

III YEAR II SEMESTER (ECE)

Presented by:

BHASKAR ENGINEERING COLLEGEYenkapally, Moinabad, Ranga Reddy.Dist-500075.

JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABADIII Year B.Tech. ECE - II Sem L T/P/D C 0 -/3/- 2DIGITAL SIGNAL PROCESSING LABThe programs shall be implemented in software (Using MATLAB / Lab view / C programming/Equivalent) and hardware (Using TI / Analog devices / Motorola / Equivalent DSP processors).1. Generation of Sinusoidal waveform / signal based on recursive difference equations2. To find DFT / IDFT of given DT signal3. To find frequency response of a given system given in (Transfer Function/ Differential equation form).4. Implementation of FFT of given sequence5. Determination of Power Spectrum of a given signal(s).6. Implementation of LP FIR filter for a given sequence.7. Implementation of HP FIR filter for a given sequence.8. Implementation of LP IIR filter for a given sequence.9. Implementation of HP IIR filter for a given sequence.10. Generation of Sinusoidal signal through filtering.11. Generation of DTMF signals.12. Implementation of Decimation Process.13. Implementation of Interpolation Process.14. Implementation of I/D sampling rate converters.15. Audio application such as to plot a time and frequency display of microphone plus a cosine using. DSP. Read a .wav file and match with their respective spectrograms.16. Noise removal: Add noise above 3 KHz and then remove, interference suppression using 400 Hz tone.17. Impulse response of first order and second order systems.Note: - Minimum of 12 experiments has to be conducted.Digital Signal Processing Lab Manual

Dep of ECE 3 BEC

CONTENTS

List of experiments using Mat lab Page No.

Introduction to MATLAB1) Generation of Basic Signals2) Sum of sinusoidal signals3) Impulse response of the difference equation4) Frequency response of a system given in Difference equation form5) Determination of Power Spectrum6) FIR Low pass Filter design7) FIR High pass Filter design8) IIR Low pass Filter design9) IIR High pass Filter design10) Fast Fourier Transform11) DFT / IDFT of given DT signal12) Implementation of Decimation Process13) Implementation of Interpolation Process14) Implementation of I/D sampling rate converters 411171921

23252933363941434648

List of experiments using CC StudioIntroduction to DSP processors, TMS 320C6745 DSK

Introduction to CC STUDIO1) Generation of Sine wave and Square wave2) Linear Convolution3) Impulse response of first order and second order systems55636872

INRODUCTIONMATLAB: MATLAB is a software package for high performance numerical computation and Visualization provides an interactive environment with hundreds of built in functions for Technical computation, graphics and animation. The MATLAB name stands for Matrix Laboratory

At its core, MATLAB is essentially a set (a toolbox) of routines (called mfiles or mex files) that sit on your computer and a window that allows you to create new variables with names (e.g. voltage and time) and process those variables with any of those routines (e.g. plot voltage against time, find the largest voltage, etc). It also allows you to put a list of your processing requests together in a file and save that combined list with a name so that you can run all of those commands in the same order at some later time. Furthermore, it allows you to run such lists of commands such that you pass in data and/or get data back out (i.e. the list of commands is like a function in most programming languages). Once you save a function, it becomes part of your toolbox (i.e. it now looks to you as if it were part of the basic toolbox that you started with). For those with computer programming backgrounds: Note that MATLAB runs as an interpretive language (like the old BASIC). That is, it does not need to be compiled. It simply reads through each line of the function, executes it, and then goes on to the next line. (In practice, a form of compilation occurs when you first run a function, so that it can run faster the next time you run it.)MATLAB Windows:MATLAB works with through three basic windows Command Window: This is the main window .it is characterized by MATLAB command Prompt >> when you launch the application program MATLAB puts you in this window all Commands including those for user-written programs, are typed in this window at the MATLAB Prompt Graphics window: the output of all graphics commands typed in the command window are Flushed to the graphics or figure window, a separate gray window with white background color The user can create as many windows as the system memory will allow Edit window: This is where you write edit, create and save your own programs in files called M files.Input-output:MATLAB supports interactive computation taking the input from the screen and flushing, the Output to the screen. In addition it can read input files and write output files Data Type: the fundamental data type in MATLAB is the array. It encompasses several distinct data objects- integers, real numbers, matrices, character strings, structures and cells. There is no need to declare variables as real or complex, MATLAB automatically sets the variable to be real. Dimensioning: Dimensioning is automatic in MATLAB. No dimension statements are required for vectors or arrays .we can find the dimensions of an existing matrix or a vector with the size and length commands.

Where to work in MATLAB?All programs and commands can be entered either in thea)Command windowb) As an M file using Mat lab editorNote: Save all M files in the folder 'work' in the current directory. Otherwise you have toLocate the file during compiling.

Typing quit in the command prompt>> quit, will close MATLAB Matlab DevelopmentEnvironment.

For any clarification regarding plot etc, which are built in functions type help topici.e. help plot

Basic Instructions in Mat lab1. T = 0: 1:10This instruction indicates a vector T which as initial value 0 and final value 10 with anIncrement of 1Therefore T = [0 1 2 3 4 5 6 7 8 9 10]2. F= 20: 1: 100Therefore F = [20 21 22 23 24 100]3. T= 0:1/pi: 1Therefore T= [0, 0.3183, 0.6366, 0.9549]4. Zeros (1, 3)The above instruction creates a vector of one row and three columns whose values areZero Output= [0 0 0]5. Zeros (2, 4)Output =0000 00006. Ones (5, 2)The above instruction creates a vector of five rows and two columnsOutput =11 11 11 11 117. a = [ 1 2 3]a.*b = [4 10 18]8. if C= [2 2 2]b.*C results in [8 10 12]b = [4 5 6]9. Plot (t, x)If x = [6 7 8 9]t = [1 2 3 4]This instruction will display a figure window which indicates the plot of x versus t

10. Stem (t, x):-This instruction will display a figure window as shown

11. Subplot: This function divides the figure window into rows and columns. Subplot (2 2 1) divides the figure window into 2 rows and 2 columns 1 represent number of the figure

Subplot (3 1 2) divides the figure window into 3 rows and 1 column 2 represent numberof the figure12. ConvSyntax: w = conv(u,v)Description: w = conv(u,v) convolves vectors u and v. Algebraically, convolution is the sameOperation as multiplying the polynomials whose coefficients are the elements of u and v.

13. DispSyntax: disp(X)Description: disp(X) displays an array, without printing the array name. If X contains a text String, the string is displayed. Another way to display an array on the screen is to type its name, but this prints a leading "X=," which is not always desirable. Note that disp does not display empty arrays.14. xlabelSyntax: xlabel('string')Description: xlabel('string') labels the x-axis of the current axes.15. ylabelSyntax : ylabel('string')Description: ylabel('string') labels the y-axis of the current axes.16. TitleSyntax: title ('string')Description: title ('string') outputs the string at the top and in the center of the current axes.17. grid onSyntax : grid onDescription: grid on adds major grid lines to the current axes.18. FFT Discrete Fourier transforms.FFT(X) is the discrete Fourier transform (DFT) of vector X. For matrices, the FFT operation is Applied to each column. For N-D arrays, the FFT operation operates on the first non-singletonDimension.FFT(X, N) is the N-point FFT, padded with zeros if X has less than N points and truncatedif it has more.19. ABS Absolute value.ABS(X) is the absolute value of the elements of X. When X is complex, ABS(X) is the complexModulus (magnitude) of the elements of X.

20. ANGLE Phase angle.ANGLE (H) returns the phase angles, in radians, of a matrix with complex elements.21. INTERP Resample data at a higher rate using low pass interpolation.Y = INTERP(X,L) resample the sequence in vector X at L times the original sample rate.The resulting resembled vector Y is L times longer, LENGTH(Y) = L*LENGTH(X).22. DECIMATE Resample data at a lower rate after low pass filtering.Y = DECIMATE(X, M) resamples the sequence in vector X at 1/M times the original Sample rate. The resulting resampled vector Y is M times shorter, i.e., LENGTH(Y) =CEIL (LENGTH(X)/M). By default, DECIMATE filters the data with an 8th order Chebyshev Type I low pass filter with cutoff frequency .8*(Fs/2)/R, before resampling.

1. GENERATION OF SIGNALSAim:- To generate the following signals using MAT LAB 20091. Unit impulse signal2. Unit step signal3. Unit ramp signal4. Exponential growing signal5. Exponential decaying signal6. Sine signal7. Cosine signalApparatus Required:- System with MAT LAB 2009Algorithm:-1. Get the number of samples.2. Generate the unit impulse, unit step using ones, zeros matrix command.3. Generate ramp, sine, cosine and exponential signals using corresponding general formula.4. Plot the graph.

Procedure:-1) Open MATLAB2) Open new M- file3) Type the program4) Save in current directory5) Compile and Run the program6) For the output see command window\ Figure window

Program:1. Unit impulse signalclc;clear all;close all;disp('UNIT I MPUL SE SIGNAL ');N=input(' Enter Number of Samples: ');n=-N:1:N;x=[zeros(1, N) 1 zeros(1, N)];stem(n, x);xlabel('Time');ylabel('Amplitude');title('Impulse Response');Output:-UNIT I MP UL SE SIGNALEnter Number of Samples: 6

2. Unit step signalclc;clear all;close all;disp('UNIT STE P SIGN AL');N=input ('Enter Number of Samples : ');n=-N: 1: N;x= [zeros(1, N) 1 ones (1, N)];stem(n, x);xlabel('Time');ylabel('Amplitude');title('Unit Step Response');Output:-UNIT ST E P SIGNALEnter Number of Samples: 6

3. Unit ramp signalclc;clear all;close all;disp('UNIT RA MP SIGN AL');N=input(' Enter Number of Samples : ');a=input('Enter Amplitude : ');n=0:1: N;x=a *n;

stem(n, x);xlabel('Time');ylabel('Amplitude');title('Unit Ramp Response');Output:-UNIT RA MP SIGNALEnter Number of Samples: 6Enter Amplitude: 20

4. Exponential decaying signalclc;clear all;close all;disp('E XPONE NT IAL DE C AYING SIGNAL ');N=input (' Enter Number of Samples: ');a=0.5;n=0:1:N;x=a. ^ n;stem(n, x);xlabel('Time');ylabel('Amplitude');title('Exponential Decaying Signal Response');Output: -E XPONE NT IAL DE CAYIN G SIGNALEnter Number of Samples: 6

5. Exponential growing signalclc;clear all;close all;disp('E XPONE NT IAL GR O WING SIGNAL ');N=input(' Enter Number of Samples : ');a=0. 5;n=0: 1: N;x=a.^ -n;stem(n, x);xlabel('Time');ylabel('Amplitude');title ('Exponential Growing Signal Response');Output:-E XPONE NT IAL GRO WING SIGN ALEnter Number of Samples: 6

6. Cosine signalclc;clear all;close all;dis p('COSINE SIGNAL ');N=input(' Enter Number of Samples : ');n=0: 1: N;x=cos(n);stem(n, x);

xlabel('Time');ylabel('Amplitude');title('Cosine Signal');Output:-COSINE SIGN ALEnter Number of Samples : 16

7. Sine signalclc;clear all;close all;disp('SINE SIGNAL ');N=input(' Enter Number of Samples : ');n=0: 1: N;x=sin (n);stem(n, x);xlabel('Time');ylabel('Amplitude');title('sine Signal');Output:-SINE SIGN ALEnter Number of Samples: 16Result:- Thus the MATLAB program for generation of all basic signals was performed and theoutput was verified.

2. Sum Of Sinusoidal SignalsAim: - To write a MATLAB program to find the sum of sinusoidal signals.Apparatus required: System with MAT LAB 2009Procedure:-1) Open MATLAB2) Open new M- file3) Type the program4) Save in current directory5) Compile and Run the program6) For the output see command window\ Figure windowProgram:-% sum of sinusoidal signalsclc;clear all;close all;tic;t=0: 01: pi;%generation of sine signalsy1=sin (t);y2=sin (3*t)/3;y3=sin (5*t)/5;y4=sin (7*t)/7;y5=sin (9*t)/9;y = sin (t) + sin (3*t)/3 + sin (5*t)/5 + sin (7*t)/7 + sin (9*t)/9;plot(t,y,t,y1,t,y2,t,y3,t,y4,t,y5);

legend('y','y1','y2','y3','y4',' y5');title ('generation of sum of sinusoidal signals');grid on;ylabel('---> Amplitude');xlabel('---> t');toc;

Output:-Result: - Thus the MATLAB program for sum of sinusoidal signals was performed and the output was Verified.

3. Impulse Response of the Difference EquationAim: - To find the impulse response of the following difference equationy(n)-y(n-1)+0.9y(n-2)= x(n)Apparatus Used: - System with MAT LAB 2009.Procedure:-1) Open MATLAB2) Open new M- file3) Type the program4) Save in current directory5) Compile and Run the program6) For the output see command window\ Figure windowProgram:-clc;clear all;close all;disp('Difference Equation of a digital system');N=input ('Desired Impulse response length = ');b=input ('Coefficients of x[n] terms = ');a=input ('Coefficients of y[n] terms = ');h=impz(b,a,N);disp('Impulse response of the system is h = ');disp(h);n=0:1: N-1;figure (1);stem (n,h);

xlabel('time index');ylabel('h[n]');title('Impulse response');figure(2);zplane(b,a);xlabel('Real part');ylabel('Imaginary part');title('Poles and Zeros of H[z] in Z-plane');Output:-Difference Equation of a digital systemDesired Impulse response length = 100Coefficients of x[n] terms = 1Coefficients of y[n] terms = [1 -1 0.9]Result:-Thus the MATLAB program for Impulse Response of Difference Equation wasperformed and the output was verified

4. Frequency Response Of A Given System Given In(Transfer Function/ Difference equation form)Aim: - To find the frequency response of the following difference equationy(n) 5 y(n1) = x(n) + 4 x(n1)Apparatus Used: - System with MAT LAB 6.5.Procedure:-1) Open MATLAB2) Open new M- file3) Type the program4) Save in current directory5) Compile and Run the program6) For the output see command window\ Figure windowProgram:-b = [1, 4]; %Numerator coefficientsa = [1, -5]; %Denominator coefficientsw = -2*pi: pi/256: 2*pi;[h] = freqz(b, a, w);subplot(2, 1, 1), plot(w, abs(h));xlabel('Frequency \omega');ylabel('Magnitude');grid on;subplot(2, 1, 2);plot(w, angle(h));xlabel('Frequency \omega');ylabel('Phase - Radians');

grid on;Output:-Result: - Thus the MATLAB program for Frequency Response of Difference Equation wasperformed and the output was verified.Note: - If the transfer function is given instead of difference equation the n perform the inverse Z-Transform and obtain the difference equation and then find the frequency response for thedifference equation using Matlab.

5. Determination Of Power SpectrumAim: To obtain power spectrum of given signal using MATLAB.Apparatus Used:- System with MAT LAB 2009.Theory: In statistical signal processing the power spectral density is a positive real function of a frequency variable associated with a stationary stochastic process, or a deterministic function of time, which has dimensions of power per Hz, or energy per Hz. It is often called simply the spectrum of the signal. Intuitively, the spectral density captures the frequency content of a stochastic process and helps identify periodicities. The PSD is the FT of autocorrelation function, R() of the signal if the signal can be treated as a wide-sense stationary random process.Procedure:-1) Open MATLAB2) Open new M- file3) Type the program4) Save in current directory5) Compile and Run the program6) For the output see command window\ Figure windowProgram:-%Power spectral densityt = 0:0.001:0.6;x = sin(2*pi*50*t)+sin(2*pi*120*t);y = x + 2*randn(size(t));figure,plot(1000*t(1:50),y(1:50));title('Signal Corrupted with Zero-Mean Random Noise');xlabel('time (milliseconds)');Y = fft(y,512);%The power spectral density, a measurement of the energy at various frequencies, is:

Pyy = Y.* conj(Y) / 512;

f = 1000*(0:256)/512;figure,plot(f,Pyy(1:257));title('Frequency content of y');xlabel('frequency (Hz)');

Output:-Result: - Thus the MATLAB program for Power Spectral Density was performed and theoutput was verified.

6. FIR Low Pass Filter DesignAim: - To Design FIR LP Filter using Rectangular/Triangular/kaiser Windowing Technique.Apparatus Used:- System with MAT LAB 2009.Algorithm:-1) Enter the pass band ripple (rp) and stop band ripple (rs).2) Enter the pass band frequency (fp) and stop band frequency (fs).3) Get the sampling frequency (f), beta value.4) Calculate the analog pass band edge frequencies, w1 and w2.w1 = 2*fp/fw2 = 2*fs/f5) Calculate the numerator and denominator6) Use an If condition and ask the user to choose either Rectangular Window or TriangularWindow or Kaiser window..7) Use rectwin,triang,kaiser commands8) Calculate the magnitude of the frequency response in decibels (dBm=20*log10(abs(h))9) Plot the magnitude response [magnitude in dB Vs normalized frequency (om/pi)]10) Give relevant names to x and y axes and give an appropriate title for the plot.11) Plot all the responses in a single figure window.[Make use of subplot]Procedure:-1) Open MATLAB2) Open new M- file3) Type the program4) Save in current directory5) Compile and Run the program6) For the output see command window\ Figure window

Program:-%FIR Filter design window techniquesclc;clear all;close all;rp=input('enter passband ripple');rs=input('enter the stopband ripple');fp=input('enter passband freq');fs=input('enter stopband freq');f=input('enter sampling freq ');beta=input('enter beta value);wp=2*fp/f;ws=2*fs/f;num=-20*log10(sqrt(rp*rs))-13;dem=14.6*(fs- fp)/f;n=ceil(num/dem);n1=n+1;if(rem(n,2)~=0)n1=n;n=n-1;endc=input('enter your choice of window function 1. rectangular 2. triangular 3.kaiser: \n ');if(c==1)y=rectwin(n1);disp('Rectangular window filter response');

endif (c==2)y=triang(n1);disp('Triangular window filter response');endif(c==3)y=kaiser(n1,beta);disp('kaiser window filter response');end%LPFb=fir1(n,wp,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));plot(o/pi,m);title('LPF');ylabel('Gain in dB-->');xlabel('(a) Normalized frequency-->');Output:-enter pass band ripple0.02enter the stop band ripple0.01enter pass band freq1000enter stop band freq1500enter sampling freq10000enter beta valueenter your choice of window function 1. rectangular 2. triangular 3.kaiser:

1Rectangular window filter responseenter your choice of window function 1. Rectangular 2. triangular 3.kaiser:2Triangular window filter responseenter beta value5enter your choice of window function 1. rectangular 2. triangular 3.kaiser:3kaiser window filter responseResult:- Thus FIR LP Filter is designed for Rectangular/triangular/kaiser windowing techniquesusing MATLAB.

7. FIR High Pass Filter DesignAim: - To Design FIR HP Filter using Rectangular/Triangular/kaiser Windowing Technique.Apparatus Used:- System with MAT LAB 2009.Algorithm:-1) Enter the pass band ripple (rp) and stop band ripple (rs).2) Enter the pass band frequency (fp) and stop band frequency (fs).3) Get the sampling frequency (f), beta value.4) Calculate the analog pass band edge frequencies, w1 and w2.w1 = 2*fp/fw2 = 2*fs/f5) Calculate the numerator and denominator6) Use an If condition and ask the user to choose either Rectangular Window or Triangularwindow or Kaiser window..7) Use rectwin,triang,kaiser commands8) Calculate the magnitude of the frequency response in decibels (dBm=20*log10(abs(h))9) Plot the magnitude response [magnitude in dB Vs normalized frequency (om/pi)]10) Give relevant names to x and y axes and give an appropriate title for the plot.11) Plot all the responses in a single figure window.[Make use of subplot]Procedure:-1) Open MATLAB2) Open new M- file3) Type the program4) Save in current directory5) Compile and Run the program6) For the output see command window\ Figure windowProgram:-%FIR Filter design window techniquesclc;clear all;close all;rp=input('enter pass band ripple');rs=input('enter the stop band ripple');fp=input('enter pass band freq');fs=input('enter stop band freq');f=input('enter sampling freq ');beta=input('enter beta value');wp=2*fp/f;ws=2*fs/f;num=-20*log10(sqrt(rp*rs))-13;dem=14.6*(fs- fp)/f;n=ceil(num/dem);n1=n+1;if(rem(n,2)~=0)n1=n;n=n-1;endc=input('enter your choice of window function 1. rectangular 2. triangular 3.kaiser: \n ');if(c==1)y=rectwin(n1);disp('Rectangular window filter response');end

if (c==2)y=triang(n1);disp('Triangular window filter response');endif(c==3)y=kaiser(n1,beta);disp('kaiser window filter response');end%HPFb=fir1(n,wp,'high',y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));plot(o/pi,m);title('HPF');ylabel('Gain in dB-->');xlabel('(b) Normalized frequency-->');Output:-enter pass band ripple0.02enter the stop band ripple0.01enter pass band freq1000enter stop band freq1500enter sampling freq10000enter beta valueenter your choice of window function 1. rectangular 2. triangular 3.kaiser:1

Rectangular window filter responseenter your choice of window function 1. rectangular 2. triangular 3.kaiser:2triangular window filter responseenter beta value5enter your choice of window function 1. rectangular 2. triangular 3.kaiser:3kaiser window filter responseResult: - Thus FIR HP Filter is designed for Rectangular/triangular/kaiser windowing techniquesusing MATLAB.

8. IIR Low Pass Filter DesignAim: -To Design and generate IIR Butterworth Analog LP Filter using MATLABApparatus Required:- System with MAT LAB 2009.Algorithm:-1) Enter the pass band ripple (rp) and stop band ripple (rs).2) Enter the pass band frequency (fp) and stop band frequency (fs).3) Get the sampling frequency (f).4) Calculate the analog pass band edge frequencies, w1 and w2.w1 = 2*fp/fw2 = 2*fs/f5) Calculate the order and 3dB cutoff frequency of the analog filter. [Make use of the followingfunction][n,wn]=buttord(w1,w2,rp,rs,s)6) Design an nth order analog lowpass Butter worth filter using the following statement.[b,a]=butter(n,wn,s)7) Find the complex frequency response of the filter by using freqs( )function[h,om]=freqs(b,a,w)where, w = 0:.01:piThis function returns complex frequency response vector h and frequency vector om inRadians/samples of the filter.8) Calculate the magnitude of the frequency response in decibels (dBm=20*log10(abs(h))9) Plot the magnitude response [magnitude in dB Vs normalized frequency (om/pi)]10) Calculate the phase response using an = angle(h)11) Plot the phase response [phase in radians Vs normalized frequency (om/pi)]

12) Give relevant names to x and y axes and gives an appropriate title for the plot.13) Plot all the responses in a single figure window.[Make use of subplot]Procedure:-1) Open MATLAB2) Open new M- file3) Type the program4) Save in current directory5) Compile and Run the program6) For the output see command window\ Figure windowProgram:-% IIR filtersclc;clear all;close all;warning off;disp('enter the IIR filter design specifications');rp=input('enter the passband ripple');rs=input('enter the stopband ripple');wp=input('enter the passband freq');ws=input('enter the stopband freq');fs=input('enter the sampling freq');w1=2*wp/fs;w2=2*ws/fs;[n,wn]=buttord(w1,w2,rp,rs,'s');disp('Frequency response of IIR HPF is:');[b,a]=butter(n,wn,'low','s');w=0:.01: pi;[h,om]=freqs(b,a,w);% Find the order n and cut off frequency% Find the filter co-efficients of LPF% Plot the frequency responsem=20*log10(abs(h));subplot(2,1,1);plot(om/pi,m);title('magnitude response of IIR Low Pass filter is:');xlabel('(a) Normalized freq. -->');ylabel('Gain in dB-->');an=angle(h);subplot(2,1,2);plot(om/pi,an);title('phase response of IIR Low Pass filter is:');xlabel('(b) Normalized freq. -->');ylabel('Phase in radians-->');Output:-enter the IIR filter design s pacificationsenter the pass band ripple 0. 15enter the stop band ripple 60enter the pass band freq1500enter the stop band freq3000enter the sampling freq7000Frequency response of IIR L PF is:Result:- Thus IIR Low Pass Filter is designed using MATLAB.9. IIR High Pass Filter DesignAim: -To Design and generate IIR Butterworth Analog HP Filter using MATLABApparatus Required:- System with MAT LAB 2009.Algorithm:-1) Enter the pass band ripple (rp) and stop band ripple (rs).2) Enter the pass band frequency (fp) and stop band frequency (fs).3) Get the sampling frequency (f).4) Calculate the analog pass band edge frequencies, w1 and w2.w1 = 2*fp/fw2 = 2*fs/f5) Calculate the order and 3dB cutoff frequency of the analog filter. [Make use of the followingfunction][n,wn]=buttord(w1,w2,rp,rs,s)6) Design an nth order analog high pass Butter worth filter using the following statement.[b,a]=butter (n,wn,high,s)7) Find the complex frequency response of the filter by using freqs( ) function[h,om]=freqs(b,a,w) where, w = 0:.01:piThis function returns complex frequency response vector h and frequency vector om inradians/samples of the filter.8) Calculate the magnitude of the frequency response in decibels (dBm=20*log10(abs(h))9) Plot the magnitude response [magnitude in dB Vs normalized frequency (om/pi)]10) Calculate the phase response using an = angle (h)11) Plot the phase response [phase in radians Vs normalized frequency (om/pi)]12) Give relevant names to x and y axes and gives an appropriate title for the plot.13) Plot all the responses in a single figure window. [Make use of subplot]

Procedure:-1) Open MATLAB2) Open new M- file3) Type the program4) Save in current directory5) Compile and Run the program6) For the output see command window\ Figure windowProgram:-% IIR filtersclc;clear all;close all;warning off;disp('enter the IIR filter design specifications');rp=input('enter the pass band ripple');rs=input('enter the stop band ripple');wp=input('enter the pass band freq');ws=input('enter the stop band freq');fs=input('enter the sampling freq');w1=2*wp/fs;w2=2*ws/fs;[n,wn]=buttord(w1,w2,rp,rs,'s');disp('Frequency response of IIR HPF is:');[b,a]=butter (n, wn,'high','s');% Find the order n and cut off frequency% Find the filter co-efficients of HPF

w=0:.01:pi;[h,om]=freqs(b,a,w);% Plot the frequency responsem=20*log10(abs(h));subplot(2,1,1);plot(om/pi,m);title('magnitude response of IIR High Pass filter is:');xlabel('(a) Normalized freq. -->');ylabel('Gain in dB-->');an=angle(h);subplot(2,1,2);plot(om/pi,an);title('phase response of IIR High Pass filter is:');xlabel('(b) Normalized freq. -->');ylabel('Phase in radians-->');Output:-enter the IIR filter design specificationsenter the pass band ripple 0. 15enter the stop band ripple 60enter the pass band freq1500enter the stop band freq3000enter the sampling freq7000Frequency response of IIR HPF is:Result:- Thus IIR High Pass Filter is designed using MATLAB.

10. Implementation Of FFTAim: To perform the FFT of signal x(n) using Mat lab.Apparatus require d: System with MAT LAB 2009.Theory: - A fast Fourier transform (FFT) is an efficient algorithm to compute the discrete Fouriertransform (DFT) and its inverse. FFTs are of great importance to a wide variety of applications,from digital signal processing and solving partial differential equations to algorithms for quickmultiplication of large integers.Evaluating the sums of DFT directly would take O(N 2) arithmetical operations. An FFTis an algorithm to compute the same result in only O(N log N) operations. In general, suchalgorithms depend upon the factorization of N, but there are FFTs with O(N log N) complexityfor all N, even for prime N. Since the inverse DFT is the same as the DFT, but with the oppositesign in the exponent and a 1/N factor, any FFT algorithm can easily be adapted for it as well.Algorithm:1) Get the input sequence2) Number of DFT point (m) is 83) Find out the FFT function using MATLAB function.4) Display the input & outputs sequence using stem functionProcedure:-1) Open MATLAB2) Open new M- file3) Type the program4) Save in current directory5) Compile and Run the program6) For the output see command window\ Figure window

Program:clear all;N=8;m=8;a=input('Enter the input sequence');n=0:1:N-1;subplot(2,2,1);stem(n,a);xlabel('Time Index n');ylabel('Amplitude');title('Sequence');x=fft(a,m);k=0:1:N-1;subplot(2,2,2);stem(k,abs(x));ylabel('magnitude');xlabel('Frequency Index K');title('Magnitude of the DFT sample');subplot(2,2,3);stem(k,angle(x));xlabel('Frequency Index K');ylabel('Phase');title('Phase of DFT sample');ylabel('Convolution');Output:-Enter the input sequence [1 1 1 1 0 0 0 0]Result:- Thus Fast Fourier Transform is Performed using Matlab.

11. Discrete Fourier Transform (DFT)Aim:- To perform the DFT of signal x(n) using Mat lab.Apparatus require d: A PC with Mat Lab 2009.Theory:- Discrete Fourier Transform (DFT) is used for performing frequency analysis ofdiscrete time signals. DFT gives a discrete frequency domain representation whereas the othertransforms are continuous in frequency domain. The N point DFT of discrete time signal x[n] is given by the equation The inverse DFT allows us to recover the sequence x[n] from the frequency samples. X(k) is a complex number (remember ejw=cosw + jsinw). It has both magnitude and phase which are plotted versus k. These plots are magnitude and phase spectrum of x[n]. The k gives us the frequency information. Here k=N in the frequency domain corresponds to sampling frequency (fs). Increasing N, increases the frequency resolution, i.e., it improves the spectral characteristics of the sequence. For example if fs=8kHz and N=8 point DFT, then in the resulting spectrum, k=1 corresponds to 1kHz frequency. For the same fs and x[n], if N=80 point DFT is computed, then in the resulting spectrum, k=1 corresponds to 100Hz frequency. Hence, the resolution in frequency is increased. Since N L, increasing N to 8 from 80 for the same x[n] implies x[n] is still the same sequence (L, the resulting operation is a decimation process by a non- integer, and when M