DIGITAL SIGNAL PROCESSING LAB
201 1
DIGITAL SIGNAL PROCESSING LAB LAB MANUAL (ECE-IV/IV I-Semester)
PREPARED BY T.SRAVANTHI /P.JAHNAVI
Department of Electronics and Communication Engineering
VIGNANA BHARATHI INSTITUTE OF TECHNOLOGY Aushapur (V), Ghatkesar (M), Rangareddy (Dt).-501301.
VBIT Page 1
DIGITAL SIGNAL PROCESSING LAB
201 1
JNTU Syllabus JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD IV Year B.Tech. ECE I-Sem 0
T
P
3
2
C
DIGITAL SIGNAL PROCESSING LAB
LIST OF EXPERIMENTS :
1. To study the architecture of DSP chips – TMS 320C 5X/6X Instructions. 2. To verify linear convolution. 3. To verify the circular convolution. 4. To design FIR filter (LP/HP) using windowing technique a) Using rectangular window b) Using triangular window c) Using Kaiser window 5. To Implement IIR filter (LP/HP) on DSP Processors 6. N-point FFT algorithm. 7. MATLAB program to generate sum of o f sinusoidal signals. 8. MATLAB program to find frequency response o f analog LP/HP filters. 9. To compute power density spectrum of a sequence. 10. To find the FFT of given 1-D signal and plot.
VBIT Page 2
DIGITAL SIGNAL PROCESSING LAB
201 1
LIST OF EXPERIMENTS CONDUCTED INDEX I.
Introduction to MATLAB
6
CYCLE-I Basic MATLAB programs 1
Basic Matrix Operations
2
Signal generat ration ,operat rations and sum of sinusoidal signals
3
20
23 27
(a) (b) (b) (c) (d) (d)
Fast Fourier Transform DFT & IDFT IDFT using using inbuil inbuiltt funct function ionss DFT DFT & IDFT IDFT usin using g equ equat atio ion n N-poin N-pointt DFT DFT & IDFT IDFT using using inbuil inbuiltt funct function ionss N-po N-poin intt DFT DFT & IDFT IDFT using using equ equat atio ion n
36
(a) (b) (c) (d)
Convolution Linear Linear conv convolu olutio tion n using using inbui inbuilt lt functi function on Linear Linear convol convoluti ution on using using equati equation on Circul Circular ar conv convolu oluti tion on using using equa equatio tion n Linear Linear convo convolut lution ion using using circu circular lar convol convoluti ution on Power Spectral Density
46
4
5
(a) Power Power Spectral Spectral Densit Density y of sum of sinusoida sinusoidall signal signal without without noise noise (b) Power Power Spectral Spectral Densit Density y of sum of sinusoida sinusoidall signal signal with with noise noise
VBIT Page 3
DIGITAL SIGNAL PROCESSING LAB
201 1
CYCLE-II IIR and FIR filters 6
IIR LPF Filters magnitude response for various order of N (a) (a) Butt Butter erwo wort rth h fil filte ter r (b) (b) Cheb Chebys yshe hev v Type Type-I -I filt filter er (c) (c) Cheb Chebys yshe hev v Typ Typee-II II filt filter er
7
51
57
(a) (a) (b) (b) (c) (c) (d) (d) (e) (e) (f) (g) (h) (i) (j) (k) (l)
IIR Digital Filter Design Butt Butter erwo worth rth Low Low Pass Pass Fil Filte ter r Butt Butter erwo worth rth High High Pas Passs Filt Filter er Butt Butter erwo worth rth Band Band Pas Passs Filt Filter er Butt Butter erwo worth rth Band Band Sto Stop p Filt Filter er Cheb Chebys yshe hev v TypeType-II Low Pas Passs Filte Filter r Chebys Chebyshev hev Type-I Type-I High High Pass Pass Filter Filter Chebys Chebyshev hev Type-I Type-I Band Band Pass Pass Filt Filter er Chebys Chebyshev hev Type-I Type-I Band Band Stop Stop Filter Filter Chebys Chebyshev hev Type-I Type-III Low Low Pass Pass Filt Filter er Chebys Chebyshev hev Type-I Type-III High High Pass Pass Filte Filter r Chebys Chebyshev hev Type-I Type-III Band Band Pass Pass Filt Filter er Chebys Chebyshev hev Type-I Type-III Band Band Stop Stop Filt Filter er
76
(a) (a) (b) (b) (c) (c) (d) (d) (e) (e) (f) (g) (h) (i) (j)
IIR Analog Filter Design Butt Butter erwo worth rth Low Low Pass Pass Fil Filte ter r Butt Butter erwo worth rth High High Pas Passs Filt Filter er Butt Butter erwo worth rth Band Band Pas Passs Filt Filter er Butt Butter erwo worth rth Band Band Sto Stop p Filt Filter er Cheb Chebys yshe hev v TypeType-II Low Pas Passs Filte Filter r Chebys Chebyshev hev Type-I Type-I High High Pass Pass Filter Filter Chebys Chebyshev hev Type-I Type-I Band Band Pass Pass Filt Filter er Chebys Chebyshev hev Type-I Type-I Band Band Stop Stop Filter Filter Chebys Chebyshev hev Type-I Type-III Low Low Pass Pass Filt Filter er Chebys Chebyshev hev Type-I Type-III High High Pass Pass Filte Filter r
8
VBIT Page 4
DIGITAL SIGNAL PROCESSING LAB
201 1
(k) Chebys Chebyshev hev Type-I Type-III Band Band Pass Pass Filt Filter er (l) Chebys Chebyshev hev Type-I Type-III Band Band Stop Stop Filt Filter er 9 (a) (a) (b) (b) (c) (c) (d) (d) (e) (e) (f)
FIR Filter Design using windows Resp Respon onse se of wind window owss Low Low pass pass fil filte terr usin using g win windo dows ws High High pas passs filt filter er usi using ng win windo dows ws Band Band pas passs filte filterr usin using g wind window owss Band Band sto stop p filt filter er usi using ng win windo dows ws FIR filter filter design design using using Kais Kaiser er wind window ow
94
CYCLE-III Code Composer Studio 10
Architecture of DSP chips-TMS 320C 6713 DSP Processor 11 Verification of convolution using CC Studio (a) (a) Line Linear ar conv convol olut utio ion n (b) (b) circ circul ular ar conv convol olut utio ion n Viva Questions
112 118
124
VBIT Page 5
DIGITAL SIGNAL PROCESSING LAB
201 1
INTRODUCTION TO MATLAB MATLAB is a high-performance language for technical computing. It integrates computation, visualization, and programming in an easy-to-use environment where problems and solutions are expressed in familiar mathematical notation. Typical uses include Math and computation Algorithm development Data acquisition Modeling, simulation, and prototyping Data analysis, exploration, and visualization Scientific and engineering graphics Application development, including graphical user interface building The name MATLAB stands for matrix laboratory . Introduction to the Desktop
Use desktop tools to manage your work and become more productive using MATLAB software. You can also use MATLAB functions to perform the equivalent of most of the features found in the desktop tools. The following illustration shows the default configuration of the MATLAB desktop. You can modify the setup to meet your needs.
VBIT Page 6
DIGITAL SIGNAL PROCESSING LAB
201 1
Arranging the Desktop
These are some common ways to customize cu stomize the desktop:
•
Show or hide desktop tools via the Desktop menu.
•
Resize any tool by dragging one of its edges.
•
Move a tool outside outside of the desktop by clicking clicking the undock button
•
Reposition a tool within the desktop by b y dragging its title bar to the new location. As you drag, a blue box indicates the new tool position until you release the mouse button. You can drag more than one tools to the same position, in which case they become the same size and their title bars become tabs. Access a tabbed tool by clicking the tab displaying its name.
•
Maximize or minimize (temporarily hide) a tool within the desktop v ia the Desktop menu.
in the tool's title title bar.
VBIT Page 7
DIGITAL SIGNAL PROCESSING LAB
201 1
•
Change fonts, customize the toolbar, and an d access other options by using File > Preferences .
Start Button
The MATLAB Start button provides easy access to tools, demos, sho rtcuts, and documentation. Click the Start button to see the options.
Command Window
Use the Command Window to enter en ter variables and to run MATLAB functions and scripts. MATLAB displays the results.
VBIT Page 8
DIGITAL SIGNAL PROCESSING LAB
201 1
Press the up arrow key ↑ to recall a statement you previously typed. Edit the statement as needed, and then press Enter to run it. For more information about entering statements in the Command Window, see Controlling Command Window Input and Output. Output. There are other tools available to help you remember functions and their syntax, and to enter statements correctly. For example, to look for functions, use the Function Browser to look for functions—click the button at the left of the the prompt to open the tool. tool. For more information information on ways to get help while you work in the Command Window, seeAvoid see Avoid Mistakes When Entering Code. Code. Command History
Statements you enter in the Command Window are logged with a timestamp in the Command History. From the Command History, you can view and search for previously run statements, as well as copy and execute selected statements. You can also create a file from selected statements.
To save the input and output from a MATLAB session to a file, use the diary function. Ways to Get Help
VBIT Page 9
DIGITAL SIGNAL PROCESSING LAB
201 1
There are different ways to get help, depending on your needs. The following table summarizes the main ways. To...
Try This
More Information
Look for getting started guides, code examples, demos, and more.
In the Help browser Contents pane, expand the listing for a product.
To open the Help browser, select Help > Product Help .
Find information about any topic.
In the Help browser search field, type words you want to look for in the documentation or demos. Then press Enter.
Searching for Documentation and Demos
View help for a function or block.
Run doc name to display doc reference page the reference page in the help reference page Help browser. For quick help in the Command Window, run help name. name. Sometimes, the help text shows function names in all uppercase letters to distinguish them from other text. When you use function names, do not use all uppercase letters.
Find a function and view help for it.
Select Help > Function Find Functions Using the Function Browser Browser, then search or browse.
Get syntax and function hints while using the Command Window and Editor.
Use colors and other Avoid Mistakes When Entering Code cues to determine correct syntax. While entering a function, pause after typing the left parenthesis. A summary of syntax options
VBIT Page 10
DIGITAL SIGNAL PROCESSING LAB
201 1
To...
Try This
More Information
displays in a temporary window. Get specific help while using a tool.
Use the context-sensitive See the documentation for a tool to learn about help, which some tools any special context-sensitive help available. provide. Access the help using standard methods, such as Help buttons and context menus.
Check code for problems and get recommendations for improvements.
In the Editor, view MLint messages.
Avoid Mistakes While Editing Code
Searching for Documentation and Demos
Use the Help browser to find documentation and demos that contain your search terms: 1. In the Help browser Search field, enter the words you want to look for. Search finds
sections containing all the words, unless you use any of the syntax options described in the following table. Option
Syntax
Example
Exact phrase
" " around phrase (quotation marks)
"word1 word2"
Wildcards for partial word searching
* in in pl place ace of of cha chara ract cter erss
wor word*
Some of the words
OR between words
word1 OR word2
Exclude words
NOT before excluded word
word1 NOT word2
2. For example, enter plot tool* label. 3. Press Enter.
The Search Results pane lists matching sections. An icon indicates the type of information.
VBIT Page 11
DIGITAL SIGNAL PROCESSING LAB
201 1
4. Arrange Arrange result results: s:
•
The default sort order is by relevance. Change the order by clicking the column header for Type or Product .
•
For results sorted by Type or Product , you can collapse and expand results for a type or product group. To expand or collapse all groups, right-click in the Search Results pane, and select the option you want from the context menu.
1. Select Select a result to view the the page.
•
The Help browser highlights the search words in the display pane. To clear highlights, select Refresh from the Actions button .
•
To see where the result is within the contents, use the navigation bar at the top of the page.
Or click the Contents tab.
VBIT Page 12
DIGITAL SIGNAL PROCESSING LAB
201 1
1. The default presentation includes previews of text for each result result found. To show more results in the Help Navigator, you can hide the previews:
•
Right-click in the Help Navigator and select Hide Previews from the context menu.
The Help Navigator only displays section titles and icons for them.
•
To see the previews again, right-click in the Help Navigator and select Show Previews
The following illustration shows the effect of hiding text previews and the context menu item for restoring them.
VBIT Page 13
DIGITAL SIGNAL PROCESSING LAB
201 1
Workspace Browser
The MATLAB workspace consists of the set of variables built up during a MATLAB session and stored in memory. You add variables to the workspace by using functions, running function and script files, and loading saved workspaces. To view the workspace and information about each variable, use the Workspace browser, or use the functions who and whos.
To delete variables from the workspace, select the variables, and then select Edit > or clear functions. functions. Delete. Alternatively, use the clearvars or clear The workspace does not persist p ersist after you end the MATLAB session. To save the workspace to a file that can be read during a later MATLAB session, select File > Save, or use the save function. Saving preserves the workspace in a binary file called a MAT-file, which has a
VBIT Page 14
DIGITAL SIGNAL PROCESSING LAB
201 1
.mat extension. You can use options to save to different formats. To read in a MAT-file, select File > Import Data, or use the load function. Variable Editor
Double-click a variable in the Workspace browser, or use openvar variablename openvar variablename,, to see it in the Variable Editor. Use the Variable Editor to view and edit a visual v isual representation of variables in the workspace.
How MATLAB Helps You Manage Files
MATLAB provides tools and functions to help you:
Find a file you want to view, change, or run
Organize your files
Ensure MATLAB can access a file so you can run or load it
Using the Current Folder Browser to Manage Files
The Current Folder browser is a key tool for managing files. Open the Current Folder browser by selecting Desktop > Current Folder from the MATLAB desktop.
VBIT Page 15
DIGITAL SIGNAL PROCESSING LAB
201 1
Use the Current Folder browser to:
•
See the contents of the current folder.
•
View and change the current folder using the address bar.
•
Find files and folders using the search tool
•
Arrange information about files and folders using the View menu.
•
Change files and folders, such as renaming or moving them.
•
Run, open, get help for, and perform other actions on the selected file or folder by rightclicking and using the context menu.
.
To create or edit a file select File > New or File > Open, or use the edit function. The following image shows the Editor with two documents, collatzall.m and collatz.m open. Notice the following:
•
Colors highlight various MATLAB language elements — blue for keywords, green for comments.
•
The code analysis message bar contains an orange box and bar, indicating there are areas for improvement in the code.
Other Editor features are described in the image.
VBIT Page 16
DIGITAL SIGNAL PROCESSING LAB
201 1
You You can can use use any any text text edit editor or to crea create te file files, s, such such as Emac Emacs. s. Use Use Edit Editor or/D /Debu ebugg gger er preferences (accessible from the desktop by selecting File > Preferences > Editor/Debugger ) to specify your default editor. If you use another editor, you still can use the MATLAB Editor for debugging, or you can use debugging functions, such as dbstop, which sets a breakpoint. To view the contents of a file, you can display the contents in the Command Window using the type function. Use code analysis to help you identify problems and potential improvements in your code. For details, see Improving and Tuning Your MATLAB Programs. Programs. You can evaluate your code in sections (called code cells). Also, you can publish your code, code, includ including ing result results, s, to popular popular output output format formatss like like HTML. HTML. For more more inform informati ation, on, see Eval Ev aluat uatee Su Subs bsec ecti tion onss of Fi File less Us Usin ing g Co Code de Ce Cell llss in the the MATL MATLAB AB Desk Deskto top p Tool Toolss and and Development Environment documentation. Identifying Problems and Areas for Improvement
Use code analysis to help you write correct and efficient MATLAB code. Code analysis:
•
Identifies areas for improvement by underlining code in orange
VBIT Page 17
DIGITAL SIGNAL PROCESSING LAB
201 1
•
Identifies errors by underlining code in red
•
Provides short messages, called Code Analyzer messages, to describe all suspected trouble spots
•
Provides extended Code Analyzer messages for many suspected trouble spots
•
Provides automated fixes for many trouble spots
The following images show code with a message at line 22 and 23. The Details button in the first message indicates that an extended message is available for that first problem. To have MATLAB fix a problem for you, click the Fix button, if displayed.
When you click a Details button, the message extends and provides a detailed explanation, a suggested action, and sometimes links to the documentation.
VBIT Page 18
DIGITAL SIGNAL PROCESSING LAB
201 1
2-D Plotting
You can visualize vectors of data with 2-D plotting functions that create:Line, area, bar, and pie charts, Direction and velocity plots ,Histograms ,Polygons and surfaces, Scatter/bubble plots, Animations
VBIT Page 19
DIGITAL SIGNAL PROCESSING LAB
201 1
CYCLE-I
VBIT Page 20
DIGITAL SIGNAL PROCESSING LAB
201 1
1. Basic Operations Operations on Matrices Matrices Aim: To write a program to perform basic operations on matrices. Software used: MATLAB 7.0.4 In built functions: 1. inv - Matrix inverse. inv(x) is the inverse of the square matrix x. A warning message is printed if x is badly b adly scaled or nearly singular.
Program: clc clear a=[1,2;3,4] b=[3,4;1,2] c=[8;2] d=[7] e=a+b f=a-b g=a*b h=b*a i=a/b j=a' k=c' l=size(h) m=inv(b) n=a.*b o=a.*d p=a./d q=a./d r=a.\b s=d.\a v=b.*c
Output: >>a =
VBIT Page 21
DIGITAL SIGNAL PROCESSING LAB
201 1
1 2 3 4 b = 3 4 1 2 c= 8 2 d= 7 e= 4 6 4 6 f= -2 -2 2 2 g= 5 8 13 20 h= 15 22 7 10 i= 0 1 1 0 j = 1 3 2 4 k= 8 2 l= 2 2 m= 1.0000 -2.0000 -0.5000 1.5000 n= 3 8 3 8 o= 7 14 21 28 p =
VBIT Page 22
DIGITAL SIGNAL PROCESSING LAB
201 1
0.1429 0.4286 q= 0.1429 0.4286 r= 3.0000 0.3333 s= 0.1429 0.4286 t= 2 4 u= 3 4
0.2857 0.5714 0.2857 0.5714 2.0000 0.5000 0.2857 0.5714
??? Error using ==> times Matrix dimensions must agree. Error in ==> matoprtns at 24 v=b.*c Result: Various matrix operations are performed and results are verified.
VBIT Page 23
DIGITAL SIGNAL PROCESSING LAB
201 1
2. Signal Signal generation, generation, operatio operations ns and sum of sinusoidal sinusoidal signals signals Aim: To write a program to generation of sinusoidal signal and perform operations on it. Software used: MATLAB 7.0.4 In built functions: 1. sin - Sine of argument in radians. sin(x) is the sine of the elements of x. 2. plot - Linear plot. plot. plot(x,y) plots vector y versus vector x. If x or y is a matrix then the vector is plotted p lotted versus the rows or columns of the matrix, whichever line up. If x is a scalar and y is a vector, length(y) disconnected points are plotted. 3. tittle - Graph title. tittle('text') adds text at the top of the current axis. 4. xlabel - x-axis label. xlabel('text') adds text beside the x-axis on the current axis. xlabel('text','Property1',PropertyValue1,'Property2',PropertyValue2,...) xlabel('text','Property1',Propert yValue1,'Property2',PropertyValue2,...) sets the values of the specified properties of the xlabel. 5. ylabel y-axis label. ylabel('text') adds text beside the Y-axis on the current axis. ylabel('text','Property1',PropertyValue1,'Property2',Property ylabel('text','Property1',Pr opertyValue1,'Property2',PropertyValue2,...) Value2,...) sets the values of the specified properties of the ylabel. 6. legend - Display legend. legend (string1,string2,string3, ...) puts a legend on the current plot using the specified strings as labels. legend works on line graphs, bar graphs, pie graphs, ribbon plots, etc. You can label any solid-colored patch or surface object. The font size and font name for for the legend strings matches the axes font size and font name. 7. grid grid - Grid lines.
VBIT Page 24
DIGITAL SIGNAL PROCESSING LAB
201 1
grid on - adds major grid lines to the current axes. grid off - removes major and minor minor grid lines from the current axes. 8. figure - Create figure window. figure, by itself, creates a new figure window, and returns its handle.
Program: clc; clear all; close all; t=-2*pi:0.01:2*pi; a=sin(t); %amplitude scaling b=2*sin(t); c=sin(t)/2; plot(t,a,t,b,t,c) title ('amplitude scaling') xlabel('time') ylabel('amplitude') legend('a','b','c') grid on %time reverse d=sin(-t); figure; plot(t,a,t,d) title ('time reverse') xlabel('time') ylabel('amplitude') legend('a','d') grid on %time scaling e=sin(2*t); f=sin(t/2) figure; plot(t,e,t,f) title ('time scaling') xlabel('time') ylabel('amplitude') legend('e','f') grid on
VBIT Page 25
DIGITAL SIGNAL PROCESSING LAB
201 1
%time shifting g=sin(t+2); h=sin(t-2); i=sin(2-t); plot(t,g,t,h,t,i) figure; title ('time shifting') xlabel('time') ylabel('amliptude') legend('g','h','i') grid on %phase shifting j=sin(t+pi/2); k=sin(t+3*pi/2); plot(t,j,t,k) figure; title ('phase shifting') xlabel('time') ylabel('amplitude') legend('j','k') grid on %sum of sinisoids l=sin(3*t)/3; m=sin(5*t)/5; n=sin(7*t)/7; o=sin(9*t)/9; p=a+l+m+n+o plot(t,a,t,m,t,n,t,o,t,p) figure; title ('sum of sinisoids') xlabel('time') ylabel('amplitude') legend('l','m','n','o','p') grid on
Output waveforms:
VBIT Page 26
DIGITAL SIGNAL PROCESSING LAB
201 1
VBIT Page 27
DIGITAL SIGNAL PROCESSING LAB
201 1
Result: Output waveforms for various operations on sinusoidal waves have been observed and verified.
3. Fast Fourier Transform Aim: To perform Fast Fourier Transform for a given sequence a) DFT & IDFT IDFT using using inbu inbuilt ilt functi functions ons b) DFT & IDFT IDFT using using equatio equation n c) N-poin N-pointt DFT & IDFT IDFT using using inbui inbuilt lt funct function ionss d) N-poin N-pointt DFT DFT & IDFT IDFT using using equat equation ion
Theory: The DFT of a sequence x(n) is X( K) =
N −1
∑ x( n) exp(− j2 ∏ nk / N)
K = 0
VBIT Page 28
DIGITAL SIGNAL PROCESSING LAB
201 1
The IDFT of the sequence X(K) is x( n) =
N −1
∑ X( K) exp( j2 ∏ nk / N) n =0
Inbuilt functions:
1. input Prompt for user input. R = input ('How many apples') gives the user the prompt in the text string and then waits for input from the keyboard. The input can be any MATLAB expression, which is evaluated, using the variables in the current workspace, and the result returned returned in R. If the user presses presses the return key without entering anything, input returns an empty matrix.
2. length Length of vector. length (X) returns the length of vector X. It is equivalent to max(size(X)) for non-empty non-empty arrays and 0 for empty ones. 3. fft Discrete Fourier Fourier transform. transform. fft(X) is the discrete Fourier 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-singleton dimension. 4. ifft Inverse discrete discrete Fourier transform. ifft(X) is the inverse discrete Fourier transform of X.
5. subplot Create axes in tiled positions. H = subplot(m,n,p), or subplot(mnp), breaks the Figure window into an m-by-n matrix of small axes, selects the p-th axes for the current plot, and returns the axis handle. 6. stem Discrete sequence or "stem" plot. stem(Y) plots the data sequence Y as stems from the x axis terminated with circles for the data value. If Y is a matrix then each column is plotted as a separate series. 7. title Graph title. TITLE('text') adds text at the top of the current axis. 8. xlabel X-axis label. xlabel ('text') adds text beside the X-axis on the current axis. xlabel ('text','Property1',PropertyValue1,'Property2',PropertyValue2,...) ('text','Property1',PropertyValue1,'Property2',PropertyValue2,...) sets the values of the specified properties of the xlabel. 9. ylabel Y-axis label. ylabel ('text') adds text beside the Y-axis on the current axis. ylabel ('text','Property1',PropertyValue1,'Property2',PropertyValue2,...) ('text','Property1',PropertyValue1,'Property2',PropertyValue2,...) sets the values of
VBIT Page 29
DIGITAL SIGNAL PROCESSING LAB
201 1
the specified properties of the ylabel.
Program: %program for DFT & IDFT using inbuilt functions clc; clear all; close all; a =input ('input sequence;'); l1 =length (a) b = fft (a) l2 = length (b) c = ifft(b) l3 = length (c) subplot(3,1,1); stem(a); title ('input sequence'); xlabel ('n'); ylabel ('amplitude'); subplot(3,1,2); stem(b); title ('dft'); xlabel ('n'); ylabel ('amplitude'); subplot(3,1,3); stem(c); title ('ifft'); xlabel ('n'); ylabel ('amplitude');
Output:
VBIT Page 30
DIGITAL SIGNAL PROCESSING LAB
201 1
%program for DFT & IDFT using equation
VBIT Page 31
DIGITAL SIGNAL PROCESSING LAB
201 1
clc; clear all; x=input('ip seq:'); N=length(x) for k=0:N-1 s(k+1)=0; for n=0:N-1 s(k+1)=s(k+1)+(x(n+1)*exp((-j*2*pi*k*n)/N)); end end s N1=length(s) for n=0:N1-1 y(n+1)=0; for k=0:N1-1 y(n+1)=y(n+1)+(s(k+1)*exp((j*2*pi*k*n)/N1)); end end y=(y/N1) subplot(3,1,1); stem(x); subplot(3,1,2); stem(abs(s)); subplot(3,1,3); stem(abs(y));
VBIT Page 32
DIGITAL SIGNAL PROCESSING LAB
201 1
OUTPUT
VBIT Page 33
DIGITAL SIGNAL PROCESSING LAB
201 1
% N-point DFT & IDFT using inbuilt functions clc; clear all; close all; a =input ('input sequence;'); l1 =length (a) N=input(‘enter input sample value’) b = fft (a,N) l2 = length (b) c = ifft(b,N) l3 = length (c) subplot(3,1,1); stem(a); title ('input sequence'); xlabel ('n'); ylabel ('amplitude'); subplot(3,1,2); stem(abs(b)); title ('dft'); xlabel ('n'); ylabel ('amplitude'); subplot(3,1,3); stem(abs(c)); title ('ifft'); xlabel ('n'); ylabel ('amplitude');
VBIT Page 34
DIGITAL SIGNAL PROCESSING LAB
201 1
Output
VBIT Page 35
DIGITAL SIGNAL PROCESSING LAB
201 1
VBIT Page 36
DIGITAL SIGNAL PROCESSING LAB
201 1
%N DFT and IDFT clc; clear all; x=input('ip seq:'); l=input('ip seq length:'); p=length(x) x=[x,zeros(1,l-p)] N=length(x) for k=0:N-1 s(k+1)=0; for n=0:N-1 s(k+1)=s(k+1)+(x(n+1)*exp((-j*2*pi*k*n)/N)); end end s N1=length(s) for n=0:N1-1 y(n+1)=0; for k=0:N1-1 y(n+1)=y(n+1)+(s(k+1)*exp((j*2*pi*k*n)/N1)); end end y=(y/N1) subplot(3,1,1); stem(x); subplot(3,1,2); stem(abs(s)); subplot(3,1,3); stem(abs(y)); OUTPUT:
ip seq:[1 1 1] p = 3 x=
VBIT Page 37
DIGITAL SIGNAL PROCESSING LAB
201 1
1
1
1
0
0
0
0
0
N = 8
s= Columns 1 through 7 3.0000 1.7071 - 1.7071i 0.2929i -0.0000 + 1.0000i Column 8 1.7071 + 1.7071i
0 - 1.0000i 0.2929 + 0.2929i 1.0000 1.000 0 + 0.0000i 0.2929 0.2 929 -
N1 = 8 y= Columns 1 through 7 1.0000 - 0.0000i 1.0000 - 0.0000i 1.0000 + 0.0000i 0.0000 + 0.0000i -0.0000 + 0.0000i 0 + 0.0000i -0.0000 - 0.0000i Column 8 0.0000 + 0.0000i
VBIT Page 38
DIGITAL SIGNAL PROCESSING LAB
201 1
Results: Fast Fourier Transform for a given sequence with & without inbuilt functions has been
observed & verified.
4. Convolution Aim: To perform convolution for two sequences
a) Linear Linear convol convoluti ution on using using inbuilt inbuilt funct function ion b) Linear Linear convol convoluti ution on using using equati equation on c) Circul Circular ar convol convoluti ution on using using equa equatio tion n d) Linear Linear convolut convolution ion using using circular circular convolution convolution
Theory: Convolution is a formal mathematical operation, just as multiplication, addition, and integration. Addition takes two numbers and produces a third number, while convolution takes two signals and produces a third signal. Convolution is used in the mathematics of many fields, such as probability and statistics. In linear systems, convolution is used to describe the relationship between three signals of interest: the input signal, the impulse response, and the output signal.
VBIT Page 39
DIGITAL SIGNAL PROCESSING LAB
201 1
In this equation, x1(k), x2(n-k) and y(n) represent the input to and output from the system at time n. Here we could see that one of the input is shifted in time by a value every time it is multiplied with the other input signal. Linear Convolution is quite often used as a method of implementing filters of various types. Circular convolution is another way of finding the convolution sum of two input signals. It resembles the linear convolution, except that the sample values of one of the input signals is folded and right shifted before the convolution sum is found. Also note that circular convolution could also be found by taking the DFT of the two input signals and finding the product of the two frequency domain signals. The Inverse DFT of the product would give the output of the signal in the time domain which is the circular convolution output. The two input signals could have been of varying sample lengths. But we take the DFT of higher point, which ever signals levels to. For eg. If one of the signal is of length length 256 and the other spans 51 samples, samples, then we could only take 256 point DFT. So the output of IDFT would be containing 256 samples instead of 306 samples, which follows N1+N2 – 1 where N1 & N2 are the lengths 256 and 51 respectively of the two inputs. Thus the output which should have been 306 samples long is fitted into 256 samples. The 256 points end up being a distorted version of the correct signal. This process is called circular convolution.
In built functions:
1.input - Prompt for user input. r = input('How many apples') gives the user the prompt in the text string and then waits for input from the keyboard. The input can be any MATLAB expression, which is evaluated, using the variables in the current workspace, workspace, and the result returned in R. If the user presses presses the return key without entering anything, INPUT INPUT returns an empty matrix.
2. length - Length of vector. length(x) returns the length of vector x. It is equivalent to max(size(x)) for non-empty arrays arrays and 0 for empty ones.
3. conv - Convolution and polynomial multiplication.
VBIT Page 40
DIGITAL SIGNAL PROCESSING LAB
201 1
c = conv(a, b) convolves vectors a and b. The resulting vector is length length length(a)+length(b)-1. If a and b are vectors v ectors of polynomial coefficients, convolving them is equivalent to multiplying the two polynomials.
4. subplot - Create axes in tiled positions. h = subplot(m,n,p), or subplot(mnp), breaks the Figure window into an m-by-n matrix of small axes, selects the p-th axes for the current plot, and returns the axis handle. 5. stem - Discrete sequence or "stem" plot. stem(y) plots the data sequence y as stems from the x axis terminated with circles for the data value. If y is a matrix then each column is plotted as a separate series. 6. tittle - Graph title. tittle('text') adds text at the top of the current axis. 7. xlabel x-axis label. xlabel('text') adds text beside the x-axis on the current axis. xlabel('text','Property1',PropertyValue1,'Property2',PropertyVal xlabel('text','Property1',Propert yValue1,'Property2',PropertyValue2,...) ue2,...) sets the values of the specified properties of the xlabel. 8. ylabel - y-axis label. ylabel('text') adds text beside the y-axis on the current axis. ylabel('text','Property1',PropertyValue1,'Property2',Propert ylabel('text','Property1',PropertyValue1,'Property2',PropertyValue2,...) yValue2,...) sets the values of the specified properties of the ylabel. 9. zeros Zeros array. zeros(N) is an N-by-N matrix of zeros. zeros (M,N) or zeros ([M,N]) is an M-by-N matrix of zeros. zeros (M,N,P,...) or zeros ([M N P ...]) is an M-by-N-by-P-by-... array of zeros. zeros (SIZE(A)) is the same size as A and all zeros. 10. grid grid - Grid lines. grid on - adds major grid lines to the current axes. grid off - removes major and minor grid lines from the current axes. . 11. max Largest component. For vectors, max (X) is the the largest element element in X. For matrices, max (X) is a row vector containing the maximum element from each column. For For N-D arrays, max (X) operates along the first non-singleton dimension. Program:
%Linear convolution using inbuilt function
VBIT Page 41
DIGITAL SIGNAL PROCESSING LAB
201 1
clc; close all; clear all; a=input(‘enter input sequence 1’); l1=length(a) b= input(‘enter input sequence 2’); l2=length(b) c=conv(a,b) l3=length(c) subplot(3,1,1) stem(a); title(‘sequence1’); xlabel(‘number of sequences’) ylabel(‘amplitude’) grid on; subplot(3,1,2) stem(b); title(‘sequence2’); xlabel(‘number of sequences’) ylabel(‘amplitude’) grid on; subplot(3,1,3) stem(c); title(‘output sequence’); xlabel(‘number of sequences’) ylabel(‘amplitude’) grid on;
Output: VBIT Page 42
DIGITAL SIGNAL PROCESSING LAB
201 1
%Linear convolution using equation clc; clear all; close all; disp ('linear convolution'); x = input ('enter input seq x(n)'); l = length (x) h = input ('enter input seq h(n)'); m = length (h) x = [ x, zeros(1,m-1)]
VBIT Page 43
DIGITAL SIGNAL PROCESSING LAB
201 1
subplot (2,2,1); stem (x); title ('input sequence'); xlabel('n'); ylabel ('x(n)'); grid; h = [h,zeros(1,l-1)] subplot(2,2,2); stem (h); title('impulse seq h(n)'); xlabel('n'); ylabel ('h(n)'); grid; y = zeros (1,l+m-1); for i = 1:l+m-1 y(i)=0; for j = 1:l+m-1 if (j < i+1) y(i) = y(i)+x(j)*h(i-j+1); y(i)+x(j)*h(i-j+1); end; end; end; y subplot(2,2,[3,4]); stem (y); title ('output sequence'); xlabel ('n'); ylabel ('y(n)'); grid;
Output
VBIT Page 44
DIGITAL SIGNAL PROCESSING LAB
201 1
VBIT Page 45
DIGITAL SIGNAL PROCESSING LAB
201 1
%Circular convolution using equation clc; close all; clear all; disp('circular convolution program'); g=input('enter input x(n)'); l1=length(g) h=input('enter input h(n)'); l2=length(h) l3=max(l1,l2) s=l1-l2 if (l2
VBIT Page 46
DIGITAL SIGNAL PROCESSING LAB
201 1
Output
VBIT Page 47
DIGITAL SIGNAL PROCESSING LAB
201 1
%Linear convolution using circular convolution clc; close all; clear all; disp('linear convolution using circular convolution program'); g=input('enter input x(n)'); l1=length(g) h=input('enter input h(n)'); l2=length(h) l3=l1+l2-1 if (l2~=l1) h=[h,zeros(1,l1-1)] g=[g,zeros(1,l2-1)] end subplot (2,2,1); stem (g); title ('input sequence'); xlabel('n'); ylabel ('g(n)'); grid; subplot(2,2,2); stem (h); title('impulse seq h(n)'); xlabel('n'); ylabel ('h(n)'); grid; for i=1:l3 y(i)=0; p=i; for j=1:l3 if(p==0) p=l3; end y(i)=y(i)+g(j)*h(p); p=p-1; end end y subplot(2,2,[3,4]); stem (y); title ('output sequence'); xlabel ('n'); ylabel ('y(n)'); grid;
VBIT Page 48
DIGITAL SIGNAL PROCESSING LAB
201 1
Output:
w ithout inbuilt functions, circular convolution & Result : convolution for two sequences with & without linear convolution using circular convolution has been observed and verified.
VBIT Page 49
DIGITAL SIGNAL PROCESSING LAB
201 1
5. Power Spectral Density Aim: Write a program to Power spectral density
a). Power Spectral Density of sum of sinusoidal signal without noise b) Power Spectral Density of sum of sinusoidal signal with noise
Theory: Power spectral density function (PSD) shows the strength of the variations (energy) as a function of frequency. In other words, it shows at which frequencies variations are strong and at which frequencies variations are weak. The unit of PSD is energy per frequency (width) and you can obtain energy within a specific frequency range by integrating PSD within that frequency range. Computation of PSD is done directly by the method called FFT or computing autocorrelation autocorrelation function and then transforming it.
In an analogy to the energy en ergy signals, let us define a function that would give us some indication of the relative relative power contribution contributionss at various frequencies, frequencies, as Sf (w). This function function has units of power per Hz and its integral yields the power in f(t) and is known as power spectral density function. Mathematically,
P=
1 2∏
∞
∫ s −∞
( d)
f ω ω
In built functions: 1. sin Sine of argument in radians. sin(X) is the sine of the elements of X. 2. plot Linear plot. plot(X,Y) plots vector Y versus vector X. If X o r Y is a matrix then the vector is plotted versus the rows or columns of the matrix, whichever line up. If X is a scalar and Y is a vector, length(Y) disconnected points are plotted. 3.randn Normally distributed random random numbers. randn(N) is an N-by-N matrix with random entries, chosen from a normal distribution with mean zero, variance one and standard standard deviation one. randn(M,N) and randn ([M,N]) are M-by-N matrices with random entries. randn (M,N,P,...) or randn ([M,N,P...]) generate random arrays. randn with no arguments is a
VBIT Page 50
DIGITAL SIGNAL PROCESSING LAB
201 1
scalar whose value changes each time it is referenced. randn (SIZE(A)) is the same size as A. 4. FIGURE Create figure window. FIGURE, by itself, creates a new figure window, and returns its handle. Program:
% Power Spectral Density of sum of sinusoidal signal without noise clc clear all fs=100; t=0:1/fs:10; x=sin(2*pi*15*t)+sin(2*pi*30*t); nfft=512; y=fft(x,nfft); f=fs*(0:nfft-1)/nfft; power=y.*conj(y)/nfft; plot(f,power); Output:
% Power Spectral Density of sum of sinusoidal signal with noise clc clear all fs=100; t=0:1/fs:4;
VBIT Page 51
DIGITAL SIGNAL PROCESSING LAB
201 1
x=sin(2*pi*15*t)+sin(2*pi*30*t); x1=x+2*randn(size(t)); nfft=512; y=fft(x1,nfft); f=fs*(0:nfft-1)/nfft; power=y.*conj(y)/nfft; plot(t,x); figure,plot(t,x1); figure,plot(f,power); Output: Input signal waveform
Input signal waveform after adding noise
VBIT Page 52
DIGITAL SIGNAL PROCESSING LAB
201 1
PSD of input signal waveform after adding noise
VBIT Page 53
DIGITAL SIGNAL PROCESSING LAB
201 1
Result: The power spectral density of a signal with & without noise has been observed &
verified.
VBIT Page 54
DIGITAL SIGNAL PROCESSING LAB
201 1
CYCLE-II
6. IIR LPF Filters magnitude response Aim: To write a program of IIR LPF Filters magnitude response for various order of N
VBIT Page 55
DIGITAL SIGNAL PROCESSING LAB
201 1
a) Butt Butter erwor worth th filt filter er b) Chebys Chebyshev hev type-I type-I filter filter c) Cheby Chebysh shev ev type type-I -III filt filter er Theory:
The IIR filter can realize both the poles and zeroes of a system because it has a rational transfer function, described by polynomials in z in both the numerator and the denominator: M
∑bk z H ( z )
−k
k =0 N
∑ a k Z
(2) −k
k =1
The difference equation for such a system is described by the following: M
y ( n) = ∑ bk x (n − k ) + k = 0
N
∑ a y (n − k ) k
(3)
k =1
M and N are order of the two polynomials bk and ak are the filter coefficients. These filter coefficients are generated using FDS (Filter Design software or Digital Filter design package).IIR filters can be expanded as infinite impulse response filters. In designing IIR filters, cutoff frequencies of the filters should be mentioned. The order of the filter can be estimated using butter worth polynomial.
Inbuilt functions: 1. sqrt:
sqrt(x) – gives the squareroot function of x 2. loglog
loglog(x) – gives the 3-dB plot
Program:
%butterworth lpf
VBIT Page 56
DIGITAL SIGNAL PROCESSING LAB
201 1
clc clear all close all g=0.8; wc=input('cut off freq in radians:'); n1=input('order of the filter:1:'); n2=input('order of the filter:2:'); n3=input('order of the filter:3:'); w=linspace(1,1000,500); for i=1:500 h2(i)=g*g/(1+(w(i)/wc)^2); h21(i)=g*g/(1+(w(i)/wc)^(2*n1)); h22(i)=g*g/(1+(w(i)/wc)^(2*n2)); h23(i)=g*g/(1+(w(i)/wc)^(2*n3)); end tf=sqrt(h2); tf1=sqrt(h21); tf2=sqrt(h22); tf3=sqrt(h23); loglog(tf); hold on loglog(tf1,'r'); hold on loglog(tf2,'g'); hold on loglog(tf3,'c'); hold off OUTPUT:
cut off freq in radians:250 orde or derr of of the the filt lter er::1:
1
orde orderr of of the the filter lter::2: orde orderr of of the the filter lter::3:
15 22
VBIT Page 57
DIGITAL SIGNAL PROCESSING LAB
201 1
%chebyshev type -1 clc clear all close all wc=input('cut off freq in radians:'); n=11; n1=12; g=0.2; e=sqrt((1/(g^2))-1) w=linspace(1,1000,500); for i=1:500 x=w(i)/wc; if(abs(x)<1) cnx=cos(n*acos(x)); end if(abs(x)>=1) cnx=cosh(n*acosh(x));
VBIT Page 58
DIGITAL SIGNAL PROCESSING LAB
201 1
end h2(i)=g*g/(1+e*e*cnx*cnx); end for i=1:500 x1=w(i)/wc; if(abs(x1)<1) cnx1=cos(n1*acos(x1)); end if(abs(x1)>=1) cnx1=cosh(n1*acosh(x1)); end h21(i)=g*g/(1+e*e*cnx1*cnx1); end tf=sqrt(h2); tf1=sqrt(h21); loglog(tf); hold on; loglog(tf1,'r'); OUTPUT: Cut off freq in radians150
VBIT Page 59
DIGITAL SIGNAL PROCESSING LAB
201 1
%chebyshev type-11 clc clear all close all wc=input('cut off freq in radians:'); n=15; n1=22; g=0.3; e=g/(sqrt(1-(g^2))) w=linspace(1,1000,500); for i=1:500 x=wc/w(i); if(abs(x)<1) cnx=cos(n*acos(x)); end if(abs(x)>=1) cnx=cosh(n*acosh(x)); end h(i)=e*cnx/sqrt(1+e*e*cnx*cnx); end for i=1:500
VBIT Page 60
DIGITAL SIGNAL PROCESSING LAB
201 1
x1=wc/w(i); if(abs(x1)<1) cnx1=cos(n1*acos(x1)); end if(abs(x1)>=1) cnx1=cosh(n1*acosh(x1)); end h1(i)=e*cnx1/sqrt(1+e*e*cnx1*cnx1); end loglog(abs(h)); hold on; loglog(abs(h1),'r');
OUTPUT: cut off freq in radians: 150
VBIT Page 61
DIGITAL SIGNAL PROCESSING LAB
201 1
Result: IIR LPF Filters (Butterworth filter, Chebyshev type-I filter, Chebyshev type-II filter)
magnitude response for various order of N.
7. IIR Digital Filter Design VBIT Page 62
DIGITAL SIGNAL PROCESSING LAB
201 1
Aim: To write a program of IIR digital filters
a) Butter Butterwor worth th low pass pass fil filter ter b) Butter Butterwor worth th high high pass pass filter filter c) Butter Butterwor worth th band band pass pass filter filter d) Butter Butterwor worth th band band stop stop filter filter e) Chebys Chebyshev hev type-I type-I low pass pass filte filter r f) Chebys Chebyshev hev type-I type-I high high pass pass filte filter r g) Chebys Chebyshev hev type-I type-I band band pass pass filter filter h) Chebys Chebyshev hev type-I type-I band band stop stop filter filter i) Chebys Chebyshev hev type-I type-III low pass pass filt filter er j) Chebys Chebyshev hev type-I type-III high high pass pass filt filter er k) Chebys Chebyshev hev type-I type-III band pass pass filt filter er l) Chebys Chebyshev hev type-I type-III band stop stop filte filter r Theory: Inbuilt functoions: 1. Buttord syntax:
[n,Wn] = buttord(Wp,Ws,Rp,Rs) [n,Wn] = buttord(Wp,Ws,Rp,Rs,'s') Description buttord calculates the minimum order of a digital d igital or analog Butterworth filter required to meet a set of filter design specifications 2. Butter
hd = butter(d) designs a Butterworth IIR digital filter using the specifications supplied in the object d. hd = butter(d,'matchexactly',match) returns a Butterworth IIR filter where the filter response matches the specified response exactly for one filter band. match, which specifies which filter band to match, is either passband--match the passband specification exactly in the final filter. stopband--match the specified stopband performance exactly in the final filter. This is the default setting.
VBIT Page 63
DIGITAL SIGNAL PROCESSING LAB
201 1
3. Cheb1ord: Syntax [n,Wn] = cheb1ord(Wp,Ws,Rp,Rs) [n,Wn] = cheb1ord(Wp,Ws,Rp,Rs,'s') Description cheb1ord calculates the minimum order of a digital or analog Chebyshev Type I filter required to meet a set of filter design specifications. 4.Cheby1: Syntax hd = cheby1(d) hd = cheby1(d,'matchexactly',match) Description hd = cheby1(d) designs a Chebyshev I IIR digital filter using the specifications supplied in the object d. 5. cheb2ord: Syntax [n,Wn] = cheb2ord(Wp,Ws,Rp,Rs) [n,Wn] = cheb2ord(Wp,Ws,Rp,Rs,'s') Description cheb2ord calculates the minimum order of a digital or analog Chebyshev Type II filter required to meet a set of filter design specifications 6. cheby2: Syntax hd = cheby2(d) hd = cheby2(d,'matchexactly',match) Description hd = cheby2(d) designs a Chebyshev II IIR digital filter using the specifications supplied in the object d. 7. freqz
Syntax [h,w] = freqz(ha) Description The next sections describe common freqz operation with adaptive, discrete-time, and multirate filters. For more input options, refer to freqz in the Signal Processing Toolbox.
VBIT Page 64
DIGITAL SIGNAL PROCESSING LAB
201 1
Program: % Butterworth low pass filter
clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N,wn]=buttord(w1,w2,rp,rs); [b,a]=butter(N,wn); w=0:0.01:pi [h,om]=freqz(b,a,w) m=20*log10(abs(h)); an=angle(h); subplot(2,1,1) plot(om/pi,m) title('butterworth magnitude response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on subplot(2,1,2) plot(om/pi,an); title('butterworth phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
…For designing of an IIR analog Chebyshev type-II filter these are the pass band ripple ,stop band ripple, pass band frequency, stop band frequency & sampling frequency values to obtain the graph
Filter LPF HPF BPF BRF
r p
r s
f p
f s
f
0 .2
45
1300
1500
10000
0 .3
16
1500
2000
9000
0 .4
35
2000
2500
10000
0 .5
40
2500
2750
7000
VBIT Page 65
DIGITAL SIGNAL PROCESSING LAB
201 1
OUTPUT:
% Butterworth high pass filter clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N,wn]=buttord(w1,w2,rp,rs); [b,a]=butter(N,wn,'high'); w=0:0.01:pi [h,om]=freqz(b,a,w)
VBIT Page 66
DIGITAL SIGNAL PROCESSING LAB
201 1
m=20*log10(abs(h)); an=angle(h); subplot(2,1,1) plot(om/pi,m) title('butterworth magnitude response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on subplot(2,1,2) plot(om/pi,an); title('butterworth phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
% Butterworth bandpass filter clc; clear all; close all; rp=input('enter passband ripple factor');
VBIT Page 67
DIGITAL SIGNAL PROCESSING LAB
201 1
rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N]=buttord(w1,w2,rp,rs); wn=[w1,w2] [b,a]=butter(N,wn,'bandpass'); w=0:0.01:pi [h,om]=freqz(b,a,w) m=20*log10(abs(h)); an=angle(h); subplot(2,1,1) plot(om/pi,m) title('butterworth bandpass magnitude response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on subplot(2,1,2) plot(om/pi,an); title('butterworth bandpass phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
VBIT Page 68
DIGITAL SIGNAL PROCESSING LAB
201 1
% Butterworth bandstop filter clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N]=buttord(w1,w2,rp,rs); wn=[w1,w2] [b,a]=butter(N,wn,'stop'); w=0:0.01:pi [h,om]=freqz(b,a,w) m=20*log10(abs(h)); an=angle(h);
VBIT Page 69
DIGITAL SIGNAL PROCESSING LAB
201 1
subplot(2,1,1) plot(om/pi,m) title('butterworth magnitude response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on subplot(2,1,2) plot(om/pi,an); title('butterworth phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
% Chebyshev type-I low pass filter
VBIT Page 70
DIGITAL SIGNAL PROCESSING LAB
201 1
clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N,wn]=cheb1ord(w1,w2,rp,rs); [b,a]=cheby1(N,rp,wn); w=0:0.01:pi [h,om]=freqz(b,a,w) m=20*log10(abs(h)); an=angle(h); subplot(2,1,1) plot(om/pi,m) title('chebysev1 magnitude response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on subplot(2,1,2) plot(om/pi,an); title('chebysev1 phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
…For designing of an IIR analog Chebyshev type-II filter these are the pass band ripple ,stop band ripple, pass band frequency, stop band frequency & sampling frequency values to obtain the graph
Filter LPF HPF BPF BRF
r p
r s
f p
f s
f
0.35
35
1500
2000
8000
0.25
40
1400
1800
7000
0 .4
40
1400
2000
9000
0 .3
46
1400
2000
8000
Output
VBIT Page 71
DIGITAL SIGNAL PROCESSING LAB
201 1
% Chebyshev type-I high pass filter clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N,wn]=cheb1ord(w1,w2,rp,rs); [b,a]=cheby1(N,rp,wn,'high'); w=0:0.01:pi [h,om]=freqz(b,a,w) m=20*log10(abs(h)); an=angle(h); subplot(2,1,1) plot(om/pi,m) title('chebysev1 magnitude response'); xlabel('normalized frequency'); ylabel('gain in db');
VBIT Page 72
DIGITAL SIGNAL PROCESSING LAB
201 1
grid on subplot(2,1,2) plot(om/pi,an); title('chebysev1 phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
Output
VBIT Page 73
DIGITAL SIGNAL PROCESSING LAB
201 1
% Chebyshev type-I bandpass filter clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N]=cheb1ord(w1,w2,rp,rs); wn=[w1,w2] [b,a]=cheby1(N,rp,wn,'bandpass'); w=0:0.01:pi [h,om]=freqz(b,a,w)
VBIT Page 74
DIGITAL SIGNAL PROCESSING LAB
201 1
m=20*log10(abs(h)); an=angle(h); subplot(2,1,1) plot(om/pi,m) title('chebysev1 magnitude response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on subplot(2,1,2) plot(om/pi,an); title('chebysev1 phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
Output
VBIT Page 75
DIGITAL SIGNAL PROCESSING LAB
201 1
% Chebyshev type-I bandstop filter clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N]=cheb1ord(w1,w2,rp,rs); wn=[w1,w2] [b,a]=cheby1(N,rp,wn,'stop'); w=0:0.01:pi [h,om]=freqz(b,a,w) m=20*log10(abs(h)); an=angle(h); subplot(2,1,1) plot(om/pi,m) title('chebysev1 magnitude response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on subplot(2,1,2) plot(om/pi,an); title('chebysev1 phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
VBIT Page 76
DIGITAL SIGNAL PROCESSING LAB
201 1
Output
% Chebyshev type-II low pass filter clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N,wn]=cheb2ord(w1,w2,rp,rs); [b,a]=cheby2(N,rs,wn); w=0:0.01:pi [h,om]=freqz(b,a,w) m=20*log10(abs(h)); an=angle(h);
VBIT Page 77
DIGITAL SIGNAL PROCESSING LAB
201 1
subplot(2,1,1) plot(om/pi,m) title('chebysev2 magnitude response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on subplot(2,1,2) plot(om/pi,an); title('chebysev2 phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
…For designing of an IIR analog Chebyshev type-II filter these are the pass band ripple ,stop band ripple, pass band frequency, stop band frequency & sampling frequency values to obtain the graph
Filter LPF HPF BPF BRF
r p
r s
f p
f s
f
0.35
35
1500
2000
8000
0.25
40
1400
1800
7000
0 .4
40
1400
2000
9000
0 .3
46
1400
2000
8000
Output
VBIT Page 78
DIGITAL SIGNAL PROCESSING LAB
201 1
% Chebyshev type-II highpass filter clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N,wn]=cheb2ord(w1,w2,rp,rs); [b,a]=cheby2(N,rs,wn,'high'); w=0:0.01:pi [h,om]=freqz(b,a,w) m=20*log10(abs(h)); an=angle(h); subplot(2,1,1) plot(om/pi,m) title('chebysev2 magnitude response'); xlabel('normalized frequency');
VBIT Page 79
DIGITAL SIGNAL PROCESSING LAB
201 1
ylabel('gain in db'); grid on subplot(2,1,2) plot(om/pi,an); title('chebysev2 phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
Output
VBIT Page 80
DIGITAL SIGNAL PROCESSING LAB
201 1
% Chebyshev type-II bandpass filter clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N]=cheb2ord(w1,w2,rp,rs); wn=[w1,w2] [b,a]=cheby2(N,rs,wn,'bandpass'); w=0:0.01:pi [h,om]=freqz(b,a,w) m=20*log10(abs(h)); an=angle(h); subplot(2,1,1) plot(om/pi,m) title('chebysev2 magnitude response'); xlabel('normalized frequency'); ylabel('gain in db');
VBIT Page 81
DIGITAL SIGNAL PROCESSING LAB
201 1
grid on subplot(2,1,2) plot(om/pi,an); title('chebysev2 phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
Output
% Chebyshev type-II band stop filter clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N]=cheb2ord(w1,w2,rp,rs); wn=[w1,w2] [b,a]=cheby2(N,rs,wn,'stop');
VBIT Page 82
DIGITAL SIGNAL PROCESSING LAB
201 1
w=0:0.01:pi [h,om]=freqz(b,a,w) m=20*log10(abs(h)); an=angle(h); subplot(2,1,1) plot(om/pi,m) title('chebysev2 magnitude response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on subplot(2,1,2) plot(om/pi,an); title('chebysev2 phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
Output
VBIT Page 83
DIGITAL SIGNAL PROCESSING LAB
201 1
Result: The IIR digital Butterworth, chebyshev type-I & chebyshev type-II waveforms has been observed and verified.
8. IIR Analog Filter Design Aim: To write a program of IIR analog filters
a) Butter Butterwor worth th low pass pass fil filter ter b) Butter Butterwor worth th high high pass pass filter filter c) Butter Butterwor worth th band band pass pass filter filter d) Butter Butterwor worth th band band stop stop filter filter e) Chebys Chebyshev hev type-I type-I low pass pass filte filter r f) Chebys Chebyshev hev type-I type-I high high pass pass filte filter r g) Chebys Chebyshev hev type-I type-I band band pass pass filter filter h) Chebys Chebyshev hev type-I type-I band band stop stop filter filter i) Chebys Chebyshev hev type-I type-III low pass pass filt filter er j) Chebys Chebyshev hev type-I type-III high high pass pass filt filter er k) Chebys Chebyshev hev type-I type-III band pass pass filt filter er l) Chebys Chebyshev hev type-I type-III band stop stop filte filter r
Program: %Butterworth low pass filter clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N,wn]=buttord(w1,w2,rp,rs,’s’); [b,a]=butter(N,wn,’s’); w=0:0.01:pi
VBIT Page 84
DIGITAL SIGNAL PROCESSING LAB
201 1
[h,om]=freqs(b,a,w) m=20*log10(abs(h)); an=angle(h); subplot(2,1,1) plot(om/pi,m) title('butterworth magnitude response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on subplot(2,1,2) plot(om/pi,an); title('butterworth phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
…For designing of an IIR analog butterworth filter these are the pass band ripple ,stop band ripple, pass band frequency, stop band frequency & sampling frequency values to obtain the graph
Filter LPF HPF BPF BRF
r p
r s
f p
f s
f
0.15
60
1500
3000
7000
0 .2
40
2000
3500
8000
0.36
36
1500
2000
6000
0.28
28
1000
1400
5000
Output
VBIT Page 85
DIGITAL SIGNAL PROCESSING LAB
201 1
%Butterworth high pass filter clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N,wn]=buttord(w1,w2,rp,rs,’s’); [b,a]=butter(N,wn,'high',’s’); w=0:0.01:pi [h,om]=freqs(b,a,w) m=20*log10(abs(h)); an=angle(h); subplot(2,1,1) plot(om/pi,m) title('butterworth magnitude response'); xlabel('normalized frequency'); ylabel('gain in db');
VBIT Page 86
DIGITAL SIGNAL PROCESSING LAB
201 1
grid on subplot(2,1,2) plot(om/pi,an); title('butterworth phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
Output
VBIT Page 87
DIGITAL SIGNAL PROCESSING LAB
201 1
%Butterworth bandpass filter clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N]=buttord(w1,w2,rp,rs,’s’); wn=[w1,w2] [b,a]=butter(N,wn,'bandpass',’s’); w=0:0.01:pi [h,om]=freqs(b,a,w) m=20*log10(abs(h)); an=angle(h); subplot(2,1,1) plot(om/pi,m) title('butterworth bandpass magnitude response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on subplot(2,1,2) plot(om/pi,an); title('butterworth bandpass phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
Output
VBIT Page 88
DIGITAL SIGNAL PROCESSING LAB
201 1
%Butterworth bandstop filter clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N]=buttord(w1,w2,rp,rs,’s’); wn=[w1,w2] [b,a]=butter(N,wn,'stop',’s’); w=0:0.01:pi [h,om]=freqs(b,a,w) m=20*log10(abs(h)); an=angle(h); subplot(2,1,1) plot(om/pi,m) title('butterworth magnitude response'); xlabel('normalized frequency');
VBIT Page 89
DIGITAL SIGNAL PROCESSING LAB
201 1
ylabel('gain in db'); grid on subplot(2,1,2) plot(om/pi,an); title('butterworth phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
Output
%Chebyshev type-I low pass filter clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor');
VBIT Page 90
DIGITAL SIGNAL PROCESSING LAB
201 1
fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N,wn]=cheb1ord(w1,w2,rp,rs,’s’); [b,a]=cheby1(N,rp,wn,’s’); w=0:0.01:pi [h,om]=freqs(b,a,w) m=20*log10(abs(h)); an=angle(h); subplot(2,1,1) plot(om/pi,m) title('chebysev1 magnitude response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on subplot(2,1,2) plot(om/pi,an); title('chebysev1 phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
…For designing of an IIR analog Chebyshev type-I filter these are the pass band ripple ,stop band ripple, pass band frequency, stop band frequency & sampling frequency values to obtain the graph
Filter LPF HPF BPF BRF
r p
r s
f p
f s
f
0.23
47
1300
1500
7800
0.29
29
900
1300
7500
0 .3
40
1400
2000
5000
0.15
30
2000
2400
7000
Output
VBIT Page 91
DIGITAL SIGNAL PROCESSING LAB
201 1
%Chebyshev type-I high pass filter clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N,wn]=cheb1ord(w1,w2,rp,rs,’s’); [b,a]=cheby1(N,rp,wn,'high',’s’); w=0:0.01:pi [h,om]=freqs(b,a,w) m=20*log10(abs(h)); an=angle(h); subplot(2,1,1)
VBIT Page 92
DIGITAL SIGNAL PROCESSING LAB
201 1
plot(om/pi,m) title('chebysev1 magnitude response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on subplot(2,1,2) plot(om/pi,an); title('chebysev1 phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
Output
%Chebyshev type-I band pass filter clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency');
VBIT Page 93
DIGITAL SIGNAL PROCESSING LAB
201 1
fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N]=cheb1ord(w1,w2,rp,rs,’s’); wn=[w1,w2] [b,a]=cheby1(N,rp,wn,'bandpass',’s’); w=0:0.01:pi [h,om]=freqs(b,a,w) m=20*log10(abs(h)); an=angle(h); subplot(2,1,1) plot(om/pi,m) title('chebysev1 magnitude response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on subplot(2,1,2) plot(om/pi,an); title('chebysev1 phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
Output
VBIT Page 94
DIGITAL SIGNAL PROCESSING LAB
201 1
%Chebyshev type-I bandstop filter clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N]=cheb1ord(w1,w2,rp,rs,’s’); wn=[w1,w2] [b,a]=cheby1(N,rp,wn,'stop',’s’); w=0:0.01:pi [h,om]=freqs(b,a,w) m=20*log10(abs(h)); an=angle(h); subplot(2,1,1) plot(om/pi,m) title('chebysev1 magnitude response');
VBIT Page 95
DIGITAL SIGNAL PROCESSING LAB
201 1
xlabel('normalized frequency'); ylabel('gain in db'); grid on subplot(2,1,2) plot(om/pi,an); title('chebysev1 phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
Output
VBIT Page 96
DIGITAL SIGNAL PROCESSING LAB
201 1
%Chebyshev type-II low pass filter clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N,wn]=cheb2ord(w1,w2,rp,rs,’s’); [b,a]=cheby2(N,rs,wn,’s’); w=0:0.01:pi [h,om]=freqs(b,a,w) m=20*log10(abs(h)); an=angle(h); subplot(2,1,1) plot(om/pi,m) title('chebysev2 magnitude response');
VBIT Page 97
DIGITAL SIGNAL PROCESSING LAB
201 1
xlabel('normalized frequency'); ylabel('gain in db'); grid on subplot(2,1,2) plot(om/pi,an); title('chebysev2 phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
…For designing of an IIR analog Chebyshev type-II filter these are the pass band ripple ,stop band ripple, pass band frequency, stop band frequency & sampling frequency values to obtain the graph
Filter LPF HPF BPF BRF
r p
r s
f p
f s
f
0 .4
50
2000
2400
10000
0.34
34
1400
1600
10000
0.37
37
3000
4000
9000
0.25
30
1300
2000
8000
Output
VBIT Page 98
DIGITAL SIGNAL PROCESSING LAB
201 1
%Chebyshev type-II high pass filter clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N,wn]=cheb2ord(w1,w2,rp,rs,’s’); [b,a]=cheby2(N,rs,wn,'high',’s’); w=0:0.01:pi [h,om]=freqs(b,a,w) m=20*log10(abs(h)); an=angle(h); subplot(2,1,1) plot(om/pi,m) title('chebysev2 magnitude response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on subplot(2,1,2) plot(om/pi,an); title('chebysev2 phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
VBIT Page 99
DIGITAL SIGNAL PROCESSING LAB
201 1
Output
%Chebyshev type-II band pass filter clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency');
VBIT Page 100
DIGITAL SIGNAL PROCESSING LAB
201 1
f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N]=cheb2ord(w1,w2,rp,rs,’s’); wn=[w1,w2] [b,a]=cheby2(N,rs,wn,'bandpass',’s’); w=0:0.01:pi [h,om]=freqs(b,a,w) m=20*log10(abs(h)); an=angle(h); subplot(2,1,1) plot(om/pi,m) title('chebysev2 magnitude response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on subplot(2,1,2) plot(om/pi,an); title('chebysev2 phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
Output
VBIT Page 101
DIGITAL SIGNAL PROCESSING LAB
201 1
%Chebyshev type-II bandstop filter clc; clear all; close all; rp=input('enter passband ripple factor'); rs=input('enter stopband ripple factor'); fp=input('enter passband frequency'); fs=input('enter passband frequency'); f=input('enter sampling frequency'); w1=(2*fp)/f;w2=(2*fs)/f; [N]=cheb2ord(w1,w2,rp,rs,’s’); wn=[w1,w2] [b,a]=cheby2(N,rs,wn,'stop',’s’); w=0:0.01:pi [h,om]=freqs(b,a,w) m=20*log10(abs(h));
VBIT Page 102
DIGITAL SIGNAL PROCESSING LAB
201 1
an=angle(h); subplot(2,1,1) plot(om/pi,m) title('chebysev2 magnitude response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on subplot(2,1,2) plot(om/pi,an); title('chebysev2 phase response'); xlabel('normalized frequency'); ylabel('gain in db'); grid on
Output
VBIT Page 103
DIGITAL SIGNAL PROCESSING LAB
201 1
Result: The IIR digital Butterworth, chebyshev type-I & chebyshev type-II waveforms has been observed and verified
9. FIR Filter Design using windows VBIT Page 104
DIGITAL SIGNAL PROCESSING LAB
201 1
Aim: To write a program of FIR Filter design using windows a) Resp Respon onse se of of wind window owss b) Low pass pass filt filter er using using window windowss c) High High pass pass filt filter er usin using g windo windows ws d) High High pass pass filt filter er using using window windowss e) High High pass pass filt filter er usin using g windo windows ws f) FIR filter filter design design using using Kaise Kaiserr windo window w
Theory: Rectangular Window The rectangular window was discussed in Chapter 4 Chapter 4 (§4.5 (§4.5)). Here we summarize the results of that discussion.
Definition (
odd):
Transform:
The DTFT of a rectangular window is shown in Fig
VBIT Page 105
DIGITAL SIGNAL PROCESSING LAB
201 1
Bartlett (``Triangular'') Window Definition:
Transform:
The DTFT of a rectangular window is shown in Fig
Hamming window Definition:
1 2 ∏ n , 0 ≤ n ≤ M − 1 c o s M 2
w[ n] =
The DTFT of a rectangular window is shown in Fig
VBIT Page 106
DIGITAL SIGNAL PROCESSING LAB
201 1
Hanning window
If y y represents the output sequence Hanning {X}, the Hanning Window VI obtains the elements of y y from yi = xi[0.54 – 0.46cos(w)]
for i for i = 0, 1, 2, …, n – 1, where n is the number of elements in the input sequence X. The DTFT of a rectangular window is shown in Fig
VBIT Page 107
DIGITAL SIGNAL PROCESSING LAB
201 1
Blackman window
2 ∏ n + 0.08 cos 4 ∏ n M M
w[ n] = 0.42 − 0.5 cos
The DTFT of a rectangular window is shown in Fig
Inbuilt functions: 1.fir1 FIR filter design using using the window method. method.
VBIT Page 108
DIGITAL SIGNAL PROCESSING LAB
201 1
B = fir1(N,Wn) designs an N'th order lowpass FIR digital filte and returns the filter coefficients in length N+1 vector B.The cut-off frequency Wn must be between 0 < Wn < 1.0, with 1.0 corresponding to half the sample rate. The filter B is real and has linear phase. The normalized gain of the filter at Wn is -6 dB. 2. boxcar Boxcar window. boxcar still works but maybe removed in the future. Use rectwin instead 3. hamming Hamming window. hamming (N) returns the N-point symmetric Hamming window in a column vector. 4.blackman Blackman window. blackman (N) returns the N-point symmetric Blackman window in a column vector. 5.bartlett Bartlett window. W = bartlett (N) returns the N-point Bartlett window. 6. hanning Hanning window. hanning (N) returns the N-point symmetric Hanning window window in a column vector. Note that the first and last zero-weighted window samples are not included. 7. kaiser Kaiser window. W = kaiser (N) returns an N-point Kaiser window in the column vector W.
Program: %Response of windows clc; close all; clear all; N=25; n=0:1:N-1; %Rectangular window w1=boxcar(N); subplot(5,2,1); plot(n,w1);
VBIT Page 109
DIGITAL SIGNAL PROCESSING LAB
201 1
w=0:0.01:pi; h1=freqz(w1,1,w); subplot(5,2,2); plot(abs(h1)); %triangular window w2=bartlett(N); subplot(5,2,3); plot(n,w2); w=0:0.01:pi; h2=freqz(w2,1,w); subplot(5,2,4); plot(abs(h2)); %hamming window w3= hamming (N); subplot(5,2,5); plot(n,w3); w=0:0.01:pi; h3=freqz(w3,1,w); subplot(5,2,6); plot(abs(h3)); %hanning window w4= hanning (N); subplot(5,2,7); plot(n,w4); w=0:0.01:pi; h4=freqz(w4,1,w); subplot(5,2,8); plot(abs(h4)); %blackman window
VBIT Page 110
DIGITAL SIGNAL PROCESSING LAB
201 1
w5= blackman (N); subplot(5,2,9); plot(n,w5); w=0:0.01:pi; h5=freqz(w5,1,w); subplot(5,2,10); plot(abs(h5));
OUTPUT:
VBIT Page 111
DIGITAL SIGNAL PROCESSING LAB
201 1
%Low pass filter using windows clc; close all; clear all; N=25; n=0:1:N-1; a=(N-1)/2; e=0.001; wc=0.5*pi; hd=(sin(wc*(n-a+e)))./(pi*(n-a+e)); %Rectangular window
VBIT Page 112
DIGITAL SIGNAL PROCESSING LAB
201 1
w1=boxcar(N); hn=hd.*w1’; w=0:0.01:pi; h=freqz(hn,1,w); subplot(3,2,1); plot(abs(h)); %triangular window w2=bartlett(N); hn1=hd.*w2’; w=0:0.01:pi; h1=freqz(hn,1,w); subplot(3,2,2); plot(abs(h1)); %hamming window w3= hamming (N); hn2=hd.*w3’; w=0:0.01:pi; h2=freqz(hn2,1,w); subplot(3,2,3); plot(abs(h2)); %hanning window w4= hanning (N); hn3=hd.*w4’; w=0:0.01:pi; h3=freqz(hn3,1,w); subplot(3,2,4); plot(abs(h3)); %blackman window w5= blackman (N);
VBIT Page 113
DIGITAL SIGNAL PROCESSING LAB
201 1
hn4=hd.*w5’; w=0:0.01:pi; h4=freqz(hn4,1,w); subplot(3,2,5); plot(abs(h4)); OUTPUT:
%High pass filter using windows clc; close all; clear all; N=25; n=0:1:N-1; a=(N-1)/2; e=0.001; wc=0.5*pi; hd=(sin(wc*(n-a+e))-(sin(pi*(n-a+e))))./(pi*(n-a+e));
VBIT Page 114
DIGITAL SIGNAL PROCESSING LAB
201 1
%Rectangular window w1=boxcar(N); hn=hd.*w1’; w=0:0.01:pi; h=freqz(hn,1,w); subplot(3,2,1); plot(abs(h)); %triangular window w2=bartlett(N); hn1=hd.*w2’; w=0:0.01:pi; h1=freqz(hn,1,w); subplot(3,2,2); plot(abs(h1)); %hamming window w3= hamming (N); hn2=hd.*w3’; w=0:0.01:pi; h2=freqz(hn2,1,w); subplot(3,2,3); plot(abs(h2)); %hanning window w4= hanning (N); hn3=hd.*w4’; w=0:0.01:pi; h3=freqz(hn3,1,w); subplot(3,2,4); plot(abs(h3)); %blackman window
VBIT Page 115
DIGITAL SIGNAL PROCESSING LAB
201 1
w5= blackman (N); hn4=hd.*w5’; w=0:0.01:pi; h4=freqz(hn4,1,w); subplot(3,2,5); plot(abs(h4)); output
%bandpasspass filter using windows clc; close all; clear all;
VBIT Page 116
DIGITAL SIGNAL PROCESSING LAB
201 1
N=25; n=0:1:N-1; a=(N-1)/2; e=0.001; wc1=0.5*pi; wc2=0.7*pi; hd=(sin(wc2*(n-a+e))-(sin(wc1*(n-a+e))))./(pi*(n-a+e)); %Rectangular window w1=boxcar(N); hn=hd.*w1’; w=0:0.01:pi; h=freqz(hn,1,w); subplot(3,2,1); plot(abs(h)); %triangular window w2=bartlett(N); hn1=hd.*w2’; w=0:0.01:pi; h1=freqz(hn,1,w); subplot(3,2,2); plot(abs(h1)); %hamming window w3= hamming (N); hn2=hd.*w3’; w=0:0.01:pi; h2=freqz(hn2,1,w); subplot(3,2,3); plot(abs(h2)); %hanning window
VBIT Page 117
DIGITAL SIGNAL PROCESSING LAB
201 1
w4= hanning (N); hn3=hd.*w4’; w=0:0.01:pi; h3=freqz(hn3,1,w); subplot(3,2,4); plot(abs(h3)); %blackman window w5= blackman (N); hn4=hd.*w5’; w=0:0.01:pi; h4=freqz(hn4,1,w); subplot(3,2,5); plot(abs(h4)); OUTPUT
VBIT Page 118
DIGITAL SIGNAL PROCESSING LAB
201 1
%bandstop filter using windows clc; close all; clear all; N=25; n=0:1:N-1; a=(N-1)/2; e=0.001; wc1=0.5*pi;
VBIT Page 119
DIGITAL SIGNAL PROCESSING LAB
201 1
wc2=0.7*pi; hd=(sin(wc1*(n-a+e))-(sin(wc2*(n-a+e)))+(sin(pi*(n-a+e))))./(pi*(n-a+e)); %Rectangular window w1=boxcar(N); hn=hd.*w1’; w=0:0.01:pi; h=freqz(hn,1,w); subplot(3,2,1); plot(abs(h)); %triangular window w2=bartlett(N); hn1=hd.*w2’; w=0:0.01:pi; h1=freqz(hn,1,w); subplot(3,2,2); plot(abs(h1)); %hamming window w3= hamming (N); hn2=hd.*w3’; w=0:0.01:pi; h2=freqz(hn2,1,w); subplot(3,2,3); plot(abs(h2)); %hanning window w4= hanning (N); hn3=hd.*w4’; w=0:0.01:pi; h3=freqz(hn3,1,w); subplot(3,2,4);
VBIT Page 120
DIGITAL SIGNAL PROCESSING LAB
201 1
plot(abs(h3)); %blackman window w5= blackman (N); hn4=hd.*w5’; w=0:0.01:pi; h4=freqz(hn4,1,w); subplot(3,2,5); plot(abs(h4)); Output:
%FIR filter design using Kaiser window clc; close all; clear all; rp=0.02; rs=0.01; fp=1000;
VBIT Page 121
DIGITAL SIGNAL PROCESSING LAB
201 1
fs=1500; f=10000; beta=5.8; 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; end y=kaiser(n1,beta); %lowpass filter b=fir1(n,wp,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,1); plot(o/pi,m); %high pass filter b=fir1(n,wp,’high’,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,2); plot(o/pi,m); %bandpass filter wn=[wp ws]; b=fir1(n,wn,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,3); plot(o/pi,m); %bandstop filter wn=[wp ws]; b=fir1(n,wn,’stop’,y); [h,o]=freqz(b,1,256);
VBIT Page 122
DIGITAL SIGNAL PROCESSING LAB
201 1
m=20*log10(abs(h)); subplot(2,2,4); plot(o/pi,m);
Output:
Result: The FIR filters using different windows has been observed & verified.
VBIT Page 123
DIGITAL SIGNAL PROCESSING LAB
201 1
CYCLE-III
10. Architecture of DSP chips-TMS 320C 6713 DSP Processor A signal can be defined as a function that conveys information, generally about the state or behavior of a physical system. There are two basic types of signals viz Analog (continuous time signals which are defined along a continuum of times) and Digital (discrete-time).
VBIT Page 124
DIGITAL SIGNAL PROCESSING LAB
201 1
Remarkably, under reasonable constraints, a continuous time signal can be adequately represented by samples, obtaining discrete time signals. Thus digital signal processing is an ideal choice for anyone who needs the performance advantage of digital manipulation along with today’s analog reality. Hence Hence a proc proces esso sorr whic which h is desi designe gned d to perf perfor orm m the the spec specia iall opera operati tions ons(d (dig igit ital al manipulations) on the digital signal within very less time can be called as a Digital signal proces processor sor.. The differ difference ence betwee between n a DSP proces processor sor,, convent convention ional al microp microproc rocess essor or and a microcontroller are listed below. Microprocessor or General Purpose Processor such as Intel xx86 or Motorola 680xx family Contains - only CPU -No RAM -No ROM -No I/O ports -No Timer Microcontroller such as 8051 family Contains - CPU - RAM - ROM -I/O ports - Timer & - Interrupt circuitry Some Micro Controllers also contain A/D, D/A and Flash Memory DSP Processors such as Texas instruments and Analog Devices
Contains - CPU - RAM -ROM - I/O ports - Timer Optimized for – fast arithmetic Extended precision Dual operand fetch Zero overhead loop Circular buffering The basic features of a DSP Processor are Feature
Use
VBIT Page 125
DIGITAL SIGNAL PROCESSING LAB
201 1
Fast-M st-Mul ulttipl iply acc accum umul ulat atee
Most Most DSP DSP al algori goritthms, hms, inclu ncludi ding ng fil filter tering, ing, trans ransfform orms, etc. etc. are are multiplication- intensive
Multiple – access memory architecture
Many data-intensive DSP operations require reading a program instruction and multiple data items during each instruction cycle for best performance
Spec Specia iali lized zed addr addres essi sing ng mode modess
Effi Effici cient ent han handl dlin ing g of dat dataa arra arrays ys and and fir first st-i -in, n, fir first st-o -out ut buf buffe fers rs in in memory
Spec Specia iali lize zed d prog progra ram m con contr trol ol
Effi Effici cien entt cont contro roll of of loo loops ps for for man many y ite itera rati tive ve DSP DSP algo algori rith thms ms.. Fast interrupt handling for frequent I/O operations.
On-chip peripherals and I/O interfaces
On-chip peripherals like A/D converters allow for small low cost system designs. Similarly I/O interfaces tailored for common peripherals allow clean interfaces to off-chip I/O devices.
ARCHITECTURE OF 6713 DSP PROCESSOR An overview of the architectural structure of the TMS320C67xx DSP, which comprises the central processing unit (CPU), memory, and on-chip peripherals. The C67xE DSPs use an advanced modified Harvard architecture that maximizes processing power with eight buses. Separate program and data spaces allow simultaneous access to program instructions and data, providing a high degree of parallelism. For example, three reads and one write can be performed in a single cycle. Instructions with parallel store and application-specific instructions fully utilize this architecture. In addition, data can be transferred between data and program spaces. Such Parallelism supports a powerful set of arithmetic, logic, and bit-manipulation operations that can all all be perfo perform rmed ed in a sing single le mach machin inee cycl cycle. e. Also Also,, the the C67xx C67xx DSP DSP incl includ udes es the the cont contro roll mechanisms to manage interrupts, repeated operations, and function calling.
Fig BLOCK DIAGRAM OF TMS 320VC 6713
VBIT Page 126
DIGITAL SIGNAL PROCESSING LAB
201 1
Bus Structure The C67xx DSP D SP architecture architecture is built around eight major 16-bit 16-bit buses (four program/data program/data buses and four address buses): _ The program bus (PB) carries the instruction code and immediate operands from program memory. _ Three data buses (CB, DB, and EB) interconnect to various elements, such as the CPU, data addres addresss genera generatio tion n logic, logic, progra program m address address generat generation ion logic, logic, on-chi on-chip p periph periphera erals, ls, and data data memory. _ The CB and DB carry the operands that are read from data memory. _ The EB carries the data to be written to memory. _ Four address buses (PAB, CAB, DAB, and EAB) carry the addresses needed for instruction execution.
VBIT Page 127
DIGITAL SIGNAL PROCESSING LAB
201 1
The C67xx DSP can generate up to two data-memory addresses per cycle using the two auxiliary register arithmetic units (ARAU0 and ARAU1). The PB can carry data operands stored in pr progr ogram spac spacee (for (for inst nstance ance,, a coef coeffficien cientt tabl able) to the mult ultipli plier and and adde adderr for multiply/accumulate operations or to a destination in data space for data move instructions (MVPD and READA). This capability, in conjunction with the feature of dual-operand read, supports the execution of single-cycle, 3-operand instructions such as the FIRS instruction. The C67xx DSP also has an on-chip bidirectional bus for accessing on-chip peripherals. This bus is connected to DB and EB through the bus exchanger in the CPU interface. Accesses that use this bus can require two or more cycles for reads and writes, depending on the peripheral’s structure.
Central Processing Unit (CPU) The CPU is common to all C67xE devices. The C67x CPU contains: _ 40-bit arithmetic logic unit (ALU) _ Two 40-bit accumulators _ Barrel shifter _ 17 × 17-bit multiplier _ 40-bit adder _ Compare, select, and store unit (CSSU) _ Data address generation unit _ Program address generation unit Arithmetic Logic Unit (ALU)
The C67x DSP performs 2s-complement arithmetic with a 40-bit arithmetic logic unit (ALU) and two 40-bit accumulators (accumulators A and B). The ALU can also perform Boolean operations. The ALU uses these inputs: _ 16-bit immediate value _ 16-bit word from data memory _ 16-bit value in the temporary register, T _ Two 16-bit words from data memory _ 32-bit word from data memory _ 40-bit word from either accumulator The The ALU ALU can can also also func functi tion on as two two 16-b 16-bit it ALUs ALUs and and perf perfor orm m two two 16-b 16-bit it oper operat atio ions ns simultaneously.
VBIT Page 128
DIGITAL SIGNAL PROCESSING LAB
201 1
Fig ALU UNIT Accumulators
Accumulators A and B store the output from the ALU or the multiplier/adder block. They can also provide a second input to the ALU; accumulator A can be an input to the multiplier/adder. Each accumulator is divided into three parts: _ Guard bits (bits 39–32) _ High-order word (bits 31–16) _ Low-order word (bits 15–0) Instructions are provided for storing the guard bits, for storing the high- and the low-order accumulator words in data memory, and for transferring 32-bit accumulator words in or out of data memory. Also, either of the accumulators can be used as temporary storage for the other. Barrel Shifter
The C67x DSP barrel shifter has a 40-bit input connected to the accumulators or to data memory (using CB or DB), and a 40-bit output connected to the ALU or to data memory (using EB). The barrel shifter can produce a left shift of 0 to 31 bits and a right shift of 0 to 16 bits on the input data. The shift requirements are defined in the shift count field of the instruction, the shift count
VBIT Page 129
DIGITAL SIGNAL PROCESSING LAB
201 1
field (ASM) of status register ST1, or in temporary register T (when it is designated as a shift count count regi regist ster er). ).Th Thee barr barrel el shif shifte terr and and the the expo exponen nentt enco encoder der norm normal aliz izee the the valu values es in an accumulator in a single cycle. The LSBs of the output are filled with 0s, and the MSBs can be either zero filled or sign extended, depending on the state of the sign-extension mode bit (SXM) in ST1. Additional shift capabilities enable the processor to perform numerical scaling, bit extraction, extended arithmetic, and overflow prevention operations. Multiplier/Adder Unit
The multip multiplie lier/a r/adde dderr unit unit perfor performs ms 17 _ 17-bit 17-bit 2s-com 2s-comple plemen mentt multi multipli plicat cation ion with with a 40-bit 40-bit addition in a single instruction cycle. The multiplier/adder block consists of several elements: a multiplier, an adder, signed/unsigned input control logic, fractional control logic, a zero detector, a rounder (2s complement), overflow/saturation logic, and a 16-bit temporary storage register (T). The multiplier has two inputs: one input is selected from T, a data-memory operand, or accumulator A; the other is selected from program memory, data memory, accumulator A, or an immedia immediate te value. value. The fast, fast, on-chi on-chip p multip multiplie lierr allows allows the C54x DSP to perfor perform m operati operations ons efficiently such as convolution, correlation, and filtering. In addition, the multiplier and ALU together execute multiply/accumulate (MAC) computations and ALU operations in parallel in a single instruction cycle. This function is used in determining the Euclidian distance and in implementing symmetrical and LMS filters, which are required for complex DSP algorithms. See section 4.5, Multiplier/Adder Unit, on page 4-19, for more details about the multiplier/adder unit. Fig MULTIPLIER/ADDER UNIT
Fig
MULTIPLIER/ADDER UNIT
VBIT Page 130
DIGITAL SIGNAL PROCESSING LAB
201 1
These are the some of the important parts of the processor and you are instructed instructed to go through through the detailed architecture once which helps you in developing the optimized code for the required application.
11. Verification of convolution using CC Studio Aim: To verify linear and circular convolution using CC Studio. Procudure to use CC Studio: I)write a C program in a notepad and save it with an extension .C. II)Creating a New Project 1.double-click the Code Composer Studio icon on your desktop
2.From the Project menu, choose New.
VBIT Page 131
DIGITAL SIGNAL PROCESSING LAB
201 1
3. 4. 5. 6. 7.
In the Project Name field, type volume1. In the Location field, browse to the working folder you created in step 1. In the Project Type field, select Executable (.out). In the Target field, select your target configuration and click Finish . The Code Composer Composer Studio™ Studio™ Program Program creates creates a project project file called called volume1.pjt volume1.pjt.. This file file stores your project settings and references the various files used by your project.
III)Adding Files to a Project 1. Choose Project→Add Files to Project . Select volume.c from the working folder you created, and click Open. You can also add ad d files to the project by right-clicking on the Project View icon and choosing Add Files to Project or by dragging and dropping files into folders in the Project View window. 2. Choose Project→Add Files to Project . Select C Source Files (*.c*, *.ccc*) in the Files of type box. Select vectors.c, and click Open. 3. Choose Project→Add Files to Project . Select Linker Command File (*.cmd, *.lcf) in the Files of type box. Select volume.cmd and click Open. This file maps sections to memory. 4. Choose Project→Add Files to Project . Go to the compiler library folder (C:\CCStudio_v3.10 C:\CCStudio_v3.10\c6000\cgtools\lib). \c6000\cgtools\lib). Select Object and Library Files (*.o*, *.l) in the file for the target you are configured for and Files of type box. Select the rts.lib click Open. This library provides run-time support for the target DSP. For some targets, the runtime library may have a more specific file name, for example, rts6200.lib. 5. Expand the Project Project list list by clicking clicking the + signs signs next to Projects, Projects, volume1.pj volume1.pjt, t, Libraries, Libraries, and Source. This list is called the Project View. This is a generic view of the project, your .lib file may differ:
VBIT Page 132
DIGITAL SIGNAL PROCESSING LAB
201 1
IV)Reviewing the Source Code 1. Double-click on the volume.c file in the Project View to open the source code in the right half of the Code Composer Studio™ window V)Building and Running the Program 1.Choose project compile file. 2. Choose project build. 3. Choose file load program debug volume.out open
4.Choose debugrun ,out put is displayed in stdout window. VI)Displaying Graphs 1. Choose View→Graph→Time/Frequency . 2. In the Graph Property Property Dialog Dialog,, change the Graph Graph Title, Start Start Address, Address, Acquisit Acquisition ion Buffer Buffer Size, Display Data Size, DSP Data Type, Autoscale, and Maximum Y-value properties to the values shown here. Scroll down or resize the dialog box to see all the properties.
VBIT Page 133
DIGITAL SIGNAL PROCESSING LAB
201 1
3. 4. 5. 6.
Click OK . An Input graph window for the Input Buffer appears. RightRight-cli click ck on the Input Input graph graph window window and and choose choose Clear Display from the pop-up menu. Choose View→Graph→Time/Frequency again. This time, time, change change the Graph Graph Title Title to Output and and the Start Start Address Address to out_buff out_buffer. er. All the the other settings are correct. 7. Click OK to display the Output graph window. Right-click on the Output graph window and choose Clear Display from the pop-up menu.
Program: % linear convolution #include main() { int m=4; int n=4; int i=0,j; int x[10]={1,2,3,4,0,0,0}; int h[10]={1,2,3,4,0,0,0}; int y[10]; for(i=0;i
VBIT Page 134
DIGITAL SIGNAL PROCESSING LAB
201 1
printf("%d\n",y[i]); } OUTPUT:
1 4 10 20 25 24 16 % circular convolution #include int m,n,x[10],y[10],i,j,temp[10],k,x2[10],a[10],h[10]; void main() { printf("enter length of first sequence\n"); scanf("%d",&m); printf("Enter length of second sequence\n"); scanf("%d",&n); printf("Enter first sequence\n"); for(i=0;in) { for(i=n;i
VBIT Page 135
DIGITAL SIGNAL PROCESSING LAB
201 1
a[0]=h[0]; for(j=1;j
VBIT Page 136
DIGITAL SIGNAL PROCESSING LAB
201 1
Viva Questions 1) What What is is samp samplin ling g theo theorem rem?? 2) What do you you mean mean by process process of reconstruct reconstruction. ion.
VBIT Page 137
DIGITAL SIGNAL PROCESSING LAB
201 1
3) What What are techni technique quess of reconst reconstruc ructio tions. ns. 4) What do you you mean Aliasing Aliasing?? What is the the condition condition to avoid avoid aliasing aliasing for sampli sampling? ng? 5) Write Write the the condit condition ionss of samp sampli ling. ng. 6) Explai Explain n the stateme statement= nt= 0:0.00 0:0.000005 0005:0. :0.05 05 7) What is is a) Under Under sampling sampling b) b) nyquist nyquist plot c) Over sampling? sampling? 8) Write Write the MATLAB MATLAB program program for over sampli sampling. ng. 9) What What is the the use use of comm command and 'leg 'legend end'? '? 10) Write the difference between built in function; plot and stem describe the function. 11) What the function is of built in function and subplot? subplot? 12) What is linear convolution? convolution? 13) Explain how convolution syntax built in in function works. 14) How to calcul calculate ate the beginn beginning ing and end of the sequence sequence for the two sided controll controlled ed output? 15) What is the total output length of linear convolution sum? 16) What is an LTI system? system? 17) Describe impulse response response of a function. function. 18) What is the difference difference between convolution and filter? 19) Where to use command filter or impz, and what is the difference between these two? 20) What is the the use o function function command 'deconv'? 21) What is the difference difference between linear and circular convolution? 22) What do you mean by statement statement subplot (3,3,1). 23) What do you mean by command "mod" and where it is used? 24) What do you mean by Autocorrelation Autocorrelation and Crosscorrelation sequences? 25) What is the difference difference between Autocorrelatio and Crsscorrelation. Crsscorrelation. 26) List all the properties properties of autocorrelation and Crosscorrelaion Crosscorrelaion sequence. 27) Where we use the inbuilt function 'xcorr' and what is the purpose of using this function? 28) How to calculate output of DFT using MATLAB? 29) 32. How to calculate output length of the linear and circular convolution. 30) 33. What do you mean by built in function 'fliplr' and where we need to use this.
VBIT Page 138
DIGITAL SIGNAL PROCESSING LAB
201 1
31) 34. What is steady state response? 32) 35. Which built in function function is used to solve a given given difference equation? 33) 36. Explain the concept of difference equation. 34) 37. Where DFT DFT is used? 35) 38. What is the difference difference between DFT and IDFT? 36) 39. What do you mean by built built in function 'abs' and where it it is used? 37) 40. What do you mean by phase spectrum and magnitude spectrum/ give comparison. comparison. 38) 41. How to compute maximum length N for a circular convolution using DFT and IDFT. IDFT. (what is 39) command). command). 40) 42. Explain the statement- y=x1.*x2 41) 43. What is FIR and IIR filter define, and distinguish distinguish between these two. 42) 44. What is filter? filter? 43) 45. What is window method? How you will design an FIR filter using window method. 44) 46. What are low-pass and band-pass filter and what is the difference between these two? 45) 47. Explain the command – N=ceil(6.6*pi/tb) N=ceil(6.6*pi/tb) 46) 48. Write down commonly used window function characteristics. 47) 49. What is the matlab matlab command for Hamming window? Explain. 48) 50. What do you you mea by cut-off cut-off frequency? 49) 51. What do you you mean by command command butter, cheby1? 50) 52. Explain the command in detail- [N,wc]=buttord(2*fp/fs,2*fstp/fs [N,wc]=buttord(2*fp/fs,2*fstp/fs,rp,As) ,rp,As) 51) 53. What is CCS? Explain Explain in detail to execute a program using using CCS. 52) 54. Why do we we need of CCS? CCS? 53) 55. How to execute a program using 'dsk' 'dsk' and 'simulator'? 54) 56. Which IC is used in in CCS? Explain the dsk, dsp kit. kit. 55) 57. What do you mean mean by noise? 56) 58. Explain the program for linear linear convolution for your given sequence. 57) 59. Why we are using command command 'float' in CCS programs. programs. 58) 60. Where we use 'float' and where we use 'int'?
VBIT Page 139
DIGITAL SIGNAL PROCESSING LAB
201 1
59) 61. Explain the command- i=(n-k)%N 60) 62. Explain the entire CCS program program in step by step step of execution.
VBIT Page 140