Dsp Matlab & Two Marks

151
Digital Signal Processing Third Edition S Poornachandra Principal Dhaanish Ahmed College of Engineering Chennai B Sasikala Assistant Professor Department of Electronics and Communication Engineering Cresent Engineering College Chennai Tata McGraw Hill Education Private Limited NEW DELHI McGraw Hill Offices New Delhi New York St Louis San Francisco Auckland Bogotá Caracas Kuala Lumpur Lisbon London Madrid Mexico City Milan Montreal San Juan Santiago Singapore Sydney Tokyo Toronto Matlab Tutorial & Two Marks Questions and Answers

Transcript of Dsp Matlab & Two Marks

Page 1: Dsp Matlab & Two Marks

Contents ● 1

Digital Signal ProcessingThird Edition

S PoornachandraPrincipal

Dhaanish Ahmed College of EngineeringChennai

B SasikalaAssistant Professor

Department of Electronics and Communication EngineeringCresent Engineering College

Chennai

Tata McGraw Hill Education Private LimitedNEW DELHI

McGraw Hill OfficesNew Delhi New York St Louis San Francisco Auckland Bogotá Caracas

Kuala Lumpur Lisbon London Madrid Mexico City Milan MontrealSan Juan Santiago Singapore Sydney Tokyo Toronto

Matlab Tutorial & Two Marks Questions and Answers

Page 2: Dsp Matlab & Two Marks

2 ● Digital Signal Processing

Published by the Tata McGraw Hill Education Private Limited,7 West Patel Nagar, New Delhi 110 008.

Digital Signal Processing, 3eMatlab Tutorial & Two Marks Questions and Answers

Copyright © 2010, by Vijay Nicole Imprints Private Limited.

No part of this publication may be reproduced or distributed in any form or by any means, electronic, mechanical,photocopying, recording, or otherwise or stored in a database or retrieval system without the prior written permission ofthe publishers and copyright holders. The program listings (if any) may be entered, stored and executed in a computersystem, but they may not be reproduced for publication.

This edition can be exported from India only by the publishers,Tata McGraw Hill Education Private Limited.

ISBN(13): 978-0-07-067279-6ISBN(10): 0-07-067279-2

Information contained in this work has been obtained by publishers, from sources believed to be reliable. However,neither publishers nor copyright holders guarantee the accuracy or completeness of any information published herein,and neither publishers nor copyright holders shall be responsible for any errors, omissions, or damages arising out ofuse of this information. This work is published with the understanding that publishers and copyright holders aresupplying information but are not attempting to render engineering or other professional services. If such services arerequired, the assistance of an appropriate professional should be sought.

Laser Typeset at: Vijay Nicole Imprints Private Limited, Chennai - 600 042

RQXCRRQFDRBRR

Page 3: Dsp Matlab & Two Marks

Contents ● 3

ContentsContentsContentsContentsContents

Preface v

Introduction to MATLAB MAT-1Two Marks Questions and Answers

Chapter 2 Introduction to Signals and Systems TQA-1

Chapter 3 LTI Systems TQA-25

Chapter 4 Fourier Series TQA-44

Chapter 5 Fourier Transform TQA-49

Chapter 6 Z-Transform TQA-80

Chapter 7 Finite Impluse Response Filter TQA-91

Chapter 8 Infinite Impluse Response Filter TQA-95

Chapter 9 Analysis of Finite Word Length Effect TQA-103

Chapter 13 State Variables TQA-106

Page 4: Dsp Matlab & Two Marks

4 ● Digital Signal Processing

Page 5: Dsp Matlab & Two Marks

Contents ● 5

PPPPPrrrrrefaceefaceefaceefaceeface

This tutorial is a supplement to the textbook Digital Signal Processing.The tutorial covers basics of MATLAB and its commands used in

introductory signals and systems to advanced digital filter design. It is meant toserve as a quick way to learn MATLAB and a quick reference to the commandsthat are used in this textbook. The best way to learn MATLAB is to sit beforecomputer with MATLAB and this tutorial material, and execute each programof this tutorial.

This tutorial also includes two marks questions and answers for selectedchapters of the book.

S PoornachandraB Sasikala

Page 6: Dsp Matlab & Two Marks

vi ● Introduction to MATLAB

Page 7: Dsp Matlab & Two Marks

Int.roduction to MATLAB

What is MATLAB?

MATLAB is a commercial "MATrix LABoratory" package ofmathwork®, which operates as an interactiveprogramming environment (www.mathworks.com). Matlab program and script files always have .m extension.The programming language is exceptionally straightforward since almost every data object is assumed to bean array. Graphical output is available to supplement numerical results.

FIe Edit _ DobUQDesktop W>ldow H.~

D ~ : j, lilt iii!!. ,. (. : Ifli r1 'v' Cu".nU'r."'",y. C."'TLAB?

Shot1cLis tlJ How to Add ld W'Iot'$ New

L

"

:N~~!'~~'.:~~",,~~, ,_".,u~,~~~:Fie TYPe~.~l~~;d~C!fi~d•,Wbin Folder Aug29,20061

'C.:.J demo. Folder Aug 29, 2006 1

l..:Jextern Folder Aug 29, 2006 1

wihelp Folder Aug 29, 2006 1L..JJo Folder Aug 29, 20061

'Wjovo Folder Aug 29, 2006 1

WJhelp Folder Aug 29, 20061

L..Jnolebook Folder Aug 29, 2006 1

W rtw Folder Aug 29, 2006 2

'W.,mulink Folder Aug 29, 2006 2

.L~~"""U::;.W.X~.ffi..9!.~Ql:Y

clearele

i;:-J c. -- 4:,'1/()7 ~':~;:~ f',t! --,.

»

To .;Jet started, lfelect MA.TLAB Help or Demo= tram ehe: Help menu.

• x

datehelpeletype he J.jJ

help.mhelp.. ;~-'/1/07 1.0 :~l Pl~ .....~

.... 2/1/07 10:)5 PMI

'I';~;:;~:!,...,

Fig. 1 MATLAB Opening Window

Page 8: Dsp Matlab & Two Marks

MAT·2 • Digital Signal Processing

MATLAB Environment

As you enter into the MATLAB environment, four default windows will be opened. They are

• Current Directory

Command History-displays complete history of commands used

• Work Space

• Command Window

The above windows can be configured by clicking 'desktop' and 'default' for all windows or can also be

customized by selecting the appropriate window.

"j ~~~liJ

To Qet ""carted, :5Ielect HATLABHelp or ~ trom the Help menu.

»

CommandWIndowOnly. __ ~_._.~_ ..__.-_.__ ._..~._ .._...._...._ ...__ . .._._.. ._.__._..__._ .._...~._ .. ... ....__

History and Command wndow J'; fI X

Allrebbed

, MAIL.A1l

File Edt '/lew Grephlcs DebuQ .~Wlndow Help

D ~. f ilItt IS ., '.~ UndockWorkspace

Shortcuts [fI How to Add [fJ V\lhllt': ~ve l~yOlt, ..

ii',,!DIS5",6ii OrlJMlize leyouts, ,

~ti1m. ail Iii. lI: _ ' .,CommendW"dow

It! Command History

v Current Directory

v Workspace

Help

Profller

v Toolbar

v Shortcuts Toolbar

.; Workspace Toobar

.; Titles

help ,mhelp

l'l:"j 1 f'M .... \

;;;.;~,.... 2/1/0"7 lD:'.:iS nthe 113 ctf.tl:, t;~

date···2/.1/0'7 1.0:4') pro!

help J,li.'1t;l~date

l/lYi' .\,):'11 PJ1a • 5;b • 10:

Fig. 2 MATLAB Environment

Page 9: Dsp Matlab & Two Marks

Introduction to MATLAB • MAT·3

Current Directory

Displays all directories and files currently in use as shown in Fig. 3.

ShorIe.t. III Howto Add III Wlot'. Now

d"I;P"'.M···U"'N!Ut1iU5'[email protected] • ,~ dO ~ ~ '[jJ8AI Files "'c ~·F11~TY~---iL~~-MO~fi~

Llhyper_shnnkage_complete.asv ASV File Apr 19,20001:09:311i[~;.p.;,:r,::~~.rI~_~~ii~=~ii~p.];':i~0.JM-file Apr 19,20001101••• ieee_1.fIg FIG-file Apr 19,200012:49:•• ieee_2.fig FIG-file Apr 19,200012:55:Drecursiveasv ASVF,le Apr19,20oo1:14:3'[irecursivem M-file Apr19,20061151

';~';kn,/ " )(

he!p.m ~lhelp

l/U7 JU:J.I PM

:_; ", 1/;)'1' .IU:J~) PM

help dau:~date:

'~! \,.... ,7;/l/(l7 10:'10 PM ·..·..thelp c1.;i.l.l;,,~

date.I/O'? 10:41 yM --1,

a • 5;b • 10;

»To get atarCed, :select HATLABHelp or Demo3 trom the Help menu.

" x

c • a+J::l;

d • s-b vi......1.....,

Fig. 3 Current Directory Environment

Page 10: Dsp Matlab & Two Marks

MAT·4 • Digital Signal Processing

Workspace

Displays the input data, intermediate data and output data. The datas displayed in the workspace can beshared with any MATLAB files.

\ MA IIAll r':lr/.l1jI'XJ

• X

-5

To get ~tarted, select HATLABHelp or Demos trom t.he Help menu.

» a EO 5;

1»b-l0;

I'» c • a+b;

» d = a-b

d •

I

.,"[CI83$

double

double

double

double

•• : Sleck:

b

EBc

tfJd

File Edit View Graphics DebuO Desktop WildOlH Help

D r;;t: ". B < -, "r1 ~. Current Directory

»

Fig. 4 Workspace Environment

Command Window

You can see the MATLAB prompt (a double arrow) in the command window as you invoke MATLAB,»

is called the command prompt. You have to type commands at the command prompt for MATLAB to execute.In command window you can type a command at command prompt, MATLAB executes the command youtyped in, then prints out the result. Once again another command prompt appear and waits for you to enteranother command.

Page 11: Dsp Matlab & Two Marks

Introduction to MATLAB • MAT·5

Click the mouse where the cursor is blinking, then type date and press the enter key. The MATLAB then

returns the following:

) MAILAIl I~ 110111'5<1

File Edit DobuQ Desl<lop W"dow Help

D ~. IItiI •• ,) (. : •• r:! : ~

Shortcut. l!J Howto Add l!J ""'.'. Now

"·,,w·wmum.u~~ ••

Current Drectory C:'II'¥1ATLAB7

• X

___ jFlle Type J La~ ~odlf_lI'd

Folder Aug 29, 20061/'

Folder AU9 29, 2006 1

Folder AU9 29, 2006 1

Folder Aug 29, 2006 1

Folder Aug 29, 2006 1

Folder Aug 29, 2006 1

Folder AU9 29, 2006 1

Folder Aug 29, 2006 1

Folder Aug 29, 2006 2

Folder Aug 29, 2006 2

datehelpeletype h,:~lphelp .mhelp

1/(1'(' .\U:J-l pr1

.I():3-~) PM --',:

help ,~latf.'date

>

COlllUHJull WlIlduw II x

To /Jet ~tarted, :select HATLABHelp or; ~ trom the Help menu.

» he 11' d"t:.~DATE Current date a:J date string.

S • DA.TEreturns a 15tring containing the date in dd-mmm-yyyy :!ormst.

Reference page in Help brow3erdoc date

» date

an:s •

Ol-Feb-2007

»

Fig. 5 Command Window Environment

To clear command window, type cle command and hit enter.

» dc

How to Leave the MATLAB Environment?

To leave the MATLAB session, type

» quit

or type

»exit

Page 12: Dsp Matlab & Two Marks

MAT·6 • Digital Signal Processing

MATLAB Help?

Help on MATLAB toolboxes are available from the command prompt. Type help and press the enter key.

» help

) MAll All 1'_ r", 11')(:

File Eelt Debug OesI<lop Window Help

D ~ ~ irlI;" ., '"' • 'd : 1> ClXrent Dlrec10ry

ShortclJts 1tJHow to Add ill Whet's New

1:. ..

- G~neral purpo!!e conrnand8.- 0pl!!!rators and special characters.- Progrartl't'ling language cowstruct!i.

Elementarv matrice:!! anti matrix memipulation.- Elementarv math function!!.- Specialized math functions.

!latrix function:!! - nume:rical linear algebra.- Data anal V:!!is and Four ier transform:!.

Interpolation and polynomials.- Function function!! and ODE solvers.- Sparse mstrices.

Annotation and Plot Editing •- Two dimensional graph!!.- Three dimen!lional graphs.- Specialized graph:!!.- Handle Graphics.- Graphical user interface tools.- Cnaracter string!l.

Image and scientific data input/output.- File input and output.- Audio and Video !lupport.- Time and date:!!.- Data types and structures.- Vl!!!rs1on control.

- COnrnelnds for creating and debugging coae.- Help commands.- Windows Operating SV!ltem Interface riles (COR/DOE)- Examples and demon:!!tra.tions.- Preference:!!.

helpH!LP topic:!

mat lab) generalmat.lab\op~mat lab\ lanamat lab\ elmat

matltib\elfunmat lab\ epec::tunmat lab) matfunmatla1:l\ datafun

me-tlab) polyfunmat lab) funtun

mat laP\ eparfunmatl8b\:!3cribematlab\qraph2dmat lab) qraph3 dmat lab\ ~pecqraphmat lab) graphic:!matlab\uitool:!mat letb\ strfun

mat lab) image:9cimat lab) iotunmat lab\ audiovideomat,lab\timefun

:mat lab\ cia-tat yp~l!Smat lab\ v~rctr 1mat lab' coctetoo13

mat lab\ helptool3mat lab\ lll'intun

"I mat la1:.l\d~roo!!~:,t.~~lbOX\ localL ......J 5f:E

--%1(1: 4-t Pll

a .5,b

-1O,

c

-a+b;d

.a-b

a - [1 2 3],b-[456J'C • III + bclearclcdateclchelp

.- 7./ .1./0'7

[tJ cr" i:I ~ .~8 . . .i"AU ..Fi~'~~=._''''_···,_'''·_·_···_··_·· '.....=:~J···F~"T·Y~······]··L~~·M·;i,·i~d==:CJbin Folder Aug 29, 20061t.Jdemos Folder Aug 29, 20061"::...:.Ie.tern Folder Aug 29, 20061::CJhelp Folder Aug 29, 20061::.:Jj. Folder Aug 29, 2006::...Jj... Folder Aug 29, 2006:WJhelp Folder Aug 29, 2006':...:.Inotebook Folder Aug 29, 2006,Wrtw Folder Aug 29, 2006 2:1'CJslrnulmk Folder Aug 29, 2006 2:0'Wst.teflow Folder Aug 29, 2006 2:

. <

g,wr!!!nt"Pi{,~g.9r.¥ \M:lrkspace

Fig. 6 MATI.AB Help

Page 13: Dsp Matlab & Two Marks

Introduction to MATLAB • MAT·7

MATLAB Documentation Help?

For beginners the complete documentation help can be obtained by pressing 'FI' key. Programmers cannavigate the content, index, document or demos by selecting the appropriate button available on left side.Detailed help on any topic can be obtained by clicking on appropriate toolbox or simply type the topic in thesearch as shown below. The right window gives the complete details and also related topics to be explored bythe user .

.' MA !LAIl r-lrf.i1lr·xJ

F~e Edit "'ie¥.' Go Favorites DebUQ Desktop Window He~

D I»' • y, ••••• <, c. , • r:1 t, C",rertOlroclory' C'MATLAB7\work

Shortcuts llJ How to Add !!J W'let's New

tiel '" x~ - -- - --~ - ---- - - - ~~ - -

• x

Noto See L ine3pec for a list of line style, marker, and color specifiers,

MATlAB Function Roforonco

Linear 2·0 plol

Syntax

p!ot (Y)Plot (Xl, VI, ... )I>J.Ot (Xl, Y1, Line5pec:, ••• )

plot ( ••. , I P.z:opertyNl2ll'te' , PropertyVe.lue, .•• )

plOt (axes_handle, 0 0 oj

h • plot ( •.. )hlines· plot('v61, ••• )

plOt (Y) plots the columns of Y versus their index if Y is a real number. If Y is complex, plot (Y) is

equj~alent to plot (real (YI, imaq(Y)) In all other uses ofp!Qt.. the imaginary component IS Ignored.

plo:e (Xl, Vl, 0 0 0) plots all lines defined by Xn ~ersus Yn pairs, If only Xn or Yn is a matrix, the vector is

plotted versus the rows or columns of the matrix, depending on whether the ~ector's raw or column dimensionmatches the matrix

plOt (Xl, Y1, L1neSpec, 0 0.1 plots all lines defined by the Xn, Yn, L1neSpe:c triples, where L1neSpec is

a line specification that determines line type, marker symbol, and color of the plotted hnes You can mix

Xn, Yn, L 1ne:Spe:c triples with Xn, Yn pairs: plOt (Xl, Yl, X2, Y2 , L1ne:Spe:c, X3, Y31 .

Description

I plotISoctio~

Curve Fitting Toolb.'··Financial Time Sar

Fived,Polnt Toolbo

Model Predictive C

RF Toolbov

Wavelet Toolbox

Simulink ReferencE

MATLA8 Funcllon!

MATLA8 Funcllon,

MATLA8 Funclion!

MATLA8 Funclion!

MATLA8 Funcllon,

MATLA8 Funcllon,

Functions

Mapping Toolbo,Neural Network Toc

Neural Nelwork TO(

Neural Network TOI

Neural Nelwork To(

Neural Network TOI

Neural Network

x •••• c •• "Tile:

Search Sypport Database go Web (or

"..,-,,_ .., _-_ ~_ "_.""_ ..,"- .._-_ " ..... !l::nmn'end W1ndo<';'i

Contents Index Search Demos,

search for' plotl

TItle

M"plot

,plotplot

'plot

plot

'plot

,plot

plot3

,plotbrowser

plot edit

:plotmatrix

plottools

,plotyyplot (phylre.J

plotm

Iplotbr

plotep

'plotes

plotpc

'plotperf

plotpv

Fig. 7 MATLAB Document Help

MATLAB utilizes the following arithmetic operators:

Arithmetic operator SvmbolAddition

+Subtraction

-Multiplication

*

Division/

Power operator

/\Transpose

,

Page 14: Dsp Matlab & Two Marks

MAT·S • Digital Signal Processing

The addition, subtraction, multiplication, division and inverse division are illustrated in Fig. 8.

) MAIlAIJ 1.1ti111'5<1

Fil. Edil DobU\l De,i<top Window H.~

CI ~ t Illii" .) '0 , •• rd ' ''f j CUronl Dlrootory: l C:~ATLAB7\w0rk

Shortcuts [iI How to Add t1J \I\ohat's New

double

double

double

double

double

double

double

• x onIDldnd Window ,. x

» a-45: "II»

b-S;»c"'a+b

e

-

50»d-a-b

d

-

40»e-a-):)

a-[123];b-[4S6];c-a+bcleareledate

". ._._. __ ••• ••n __ ·_· __ • •••__ •••~ _

'<"'<'\<H'" iL::1» ~ X

1<1

i

.-

225

» t""a/b

t -

U/U') 12~IJOi;.Ha-45;b-5; » q-a\bc-a+bd-a-b g •

I

./:1 0.1111y~:!

,J:: 1» .,~!

Fig. 8 Arithmetic Operations

Page 15: Dsp Matlab & Two Marks

Introduction to MATLAB • MAT·9

The power operator and inverse operation are illustrated in Fig. 9.

'MAIIAU f.Jrd'WxjFile Edit Clebo.JQ Oesl<top W"dow Help

[l ~ J lttol IlL·; , • '!1 t Current DIrectory: C .••••'ATL~~~"':"••.I~ .

Shortcuts [tJ How to Add 1tI \M1elt's New

.•~ I§' 111 =i1 ••. 'III •••• stock:;

m;e ·"=Jt~=.:~=·=~=.:~=]d~:~:I.EB b 3 doubl.EB c 64 doubl.EB d [1 23,456;7 8 91 doubl.EB. [1 47,258;3691 doubl.

• X

·r)!mmiliiDinil-Wttllll\TldIillJ.lIllUIII ••••••••••••••••••••• ·.1» 5.-4;» b-3;» c·aAb

le-

I 6'1» d- (1 2 3; 'I 5 6; 7 8 9J

d'

36

9

clearelea-2S;b"S;c·a"bclearelea-"i;b-3;

d" [1 Z 3; 4 5 6; 7 8 9J

»

Fig. 9 Arithmetic Operations (continued ... )

Representation of Complex Number

There are several pre-defined value for variables such as ior j is ~ and n is 3.1416 .... Similarly, there areseveral pre-defined functions that can be used in computations. The complex number representation is illustratedin Fig. 10.

Pre-defined functionabs

An Ie

cos

sin

ex

Page 16: Dsp Matlab & Two Marks

MAT·10 • Digital Signal Processing

, MAli All 1'_ 11'>'1'l[x1File Edit Debug Desktop ~ ~

D ~ .K •••.• ') ':"~ : _ rJ : 'f CUrren Drectory. (:~i~~~:~:~:~~'-.ShortciAs 1] How to Acid 1tJ VIhIt's New

eleclearele

• X

•.. Stlde:'

u~,w,w~~, __ ,,_~j Cia ••

double

double

double (complex)

double

double

double

double

» .-3;» b-4;» C" (a+j *b)

3.0000 + ''l.00001

» d-abl' (e)

d •

» e:-snqle (e)

0.9273

: » t-cos (a)

t -

.IMi .• p

clearele0.-3;b-4:c· (a+j *b)d-sbs (e)e-angle (c)f·co!! (s)'Q'-exp (a)

~.:, ,~".....

in

Matrix Representation

-0.9900

» g-exp (a)

, t;J ••

20,0855Vi

.1 » I

"'1",,+, •••• ",. iNih!

Fig. 10 Representation of Complex Numbers

•__ w"

MATLAB is based on matrix and vector algebra. The scalars are also treated as I x I matrices.

Vectors can be generated in two ways:

• Equally spaced elements

• Unequally spaced elements

Equally spaced elements The equally spaced elements can be generated by the following command.

x=O: I : 6;

creates a I x 6 vector with the elements 0, I, 2, 3, 4, 5, 6. The first digit in the command gives the initial Value to

be generated, second digit represent the increment to be generated (in this example it is I) and the last digitrepresent the last value to be generated.

x=O :6;

This command also generates a vector of! x 6 with the elements 0, I, 2, 3, 4, 5, 6. In MATLAB, if the

increment digit is not specified, then it is set to a default of I.

Page 17: Dsp Matlab & Two Marks

Introduction to MATLAB • MAT·11

Unequally spaced elements Unequally spaced vectors can be generated by entering the values directlywith in square bracket with a space between two digits.

y=[137841];

Additional element can be added to the vector:

y(7) = 9;

yields the vector

y = [I 3 784 I 9];

It is also possible to join two vectors:

u = [2 5 II];

v=[yu];

then

v=[13784192511];

The equally spaced and unequally spaced elements are generated in MATLAB environment as illustrated

in Fig. II(a).

Fie Ecit Debull Oesi<lap Window Help

D ~ . ,X ilil. ,.)(•••• r! •l' Curren D1roc!oty: c: .••••\TL•••137\w<"k

Shortc\A:s III How to Adcl [lJ V'mcrt's New

(,:~lnmmd JNbtk\i'f",,'."'__'__"__ , __.....~ ·,····~'''~.,,''''''''''''''_w'' ·_·_·.".,__

..~ •• =•••

• Nome·; ··Tvolue

tIlu (138491525671

EEl v 15671

EBw /138491521

EEl x (01234561

/BY 101234561

•••doubl.

doubl.

double

double

doubl.

• X

» x • 0:1:6

x -

o

» y • 0: 6

y -

o

» w - [1 3 e 1 9 15]

5

• X

••I,

e 9 15

b-1;c- (i!t.+j 1tb)

d-ab.(c)e-angle (e)f·co15 Is)g-exp (al

'.:;,'~, .... 3/1"'1/U7 '",: 1.4 PMx • 0:1:6y - 0: 6w - [1 3 e 1 9 15]w(7)-2

v-[567]:u • [w v]

w -

»v-[567]:» u • Tv v)

u -

e 9 15

9 15 7

Fig. 11(a) Generation of Elements of Matrices

Page 18: Dsp Matlab & Two Marks

MAT·12 • Digital Signal Processing

Matrices are defined by entering the elements row by row:

V=(137;841;925];

creates the matrix.

Special Matrices

Following are special matrices:

Type of Matrix MATLABcodeNull Matrix

m = r 1;

n x m matrix of zerosm = zeros(n, m);

n x m matrix of onesm = ones(n, m);

n x m identity matrix

m = eye(n);

[n n x m matrix, the 'n' represents the number of rows and 'm' represents the number of column. The

special matrices are illustrated in Fig. ll(b).

File Edt DebuQ Desktop Window Help

D ~ ,K!lJio. <; '. JIi '!1 't Current DIrectory;

Shortcuts 1tJ How to Add lll. W"lat's ~w

.~II' • =... 'iIi •• ' Slack:>;

j;eINt'"; 56;7891'''''':::]~o~:leEE y1 <3x4 double> double

EE y2 <4x3 double> double

EE y3 1100;0 1 0;00 11 double

" X ommand Window "" x

» V-[l 2 3;4 5 6;1 8 9]

v -

»Vl-2il!!!ro!l(3,4)

Vl

-

a

aDaa

aDaa

aaD

»v2-one!! (4, 3)

('~.. ,•X

Vl

-[]!#IV2

.v2-zl!ro.!l(3,40 clearclcV' [1

23;456; 189]Vl

-[Jy2

-zero:il (3, 4}

y3

.one!l(4,3) »V3..V. (3)clear clc

V3-

V- [123;456;189J

Vl

-zero!! (3,4) 1av2

.onel!l(4/3) aav3

-eye (3) Via 1

..~.. ~)

Fig. 11(b) Generation of Special Matrices

Page 19: Dsp Matlab & Two Marks

Introduction to MATLAB • MAT·13

A value can be assigned to a particular element of a matrix using the command:

v(l,3)=6;

as illustrated in Fig. 12.

'MAIlAIl 1_11d'lfxlFU. Edt Dobu'l Dosl<lop W"dow Help

CI ~ ii, 1IliI" .) " i iii rd i l' i Current Directory

Shortcuts III How to Add itJ W'lllt's New

··tIi m _ =ii. 'fill.' Stock!iL,i .Name ":":"",,,:,,:,,:,:::::].~~~:::,,,::::.':«::,::,::,_"·· ..m...••.•.•.•"""'''',, •• I.C:::••••

Hl"~'" [1 23105671 double

EB I <3,4 double> double

y3 • oyo(3)

J/lS/(17 ?·:~:4 AM .....\

clear010

1-eve(3,4)1(2,3) -6k - [1 2 3 4: 1 1 1 1: 5 5 5 5]So • 1+k

clC!sr010

~ - [1 2 3 4 5 6 7]~(41'101 - 090(3,4)1(2,3) - 5

• x ommalld Vtlmdow ,. x

7

Fig. 12 Inclusion of Element in a Matrix

Addition, subtraction, multiplication and division of matrix can be done using MATLAB is illustrated in

Figs. 13-15.

Page 20: Dsp Matlab & Two Marks

MAT·14 • Digital Signal Processing

".. fdit DIbJg Dnktop WIndow ..,

Cl l» ~ .~ ~ •• ~') ('j • r:!l , t ~CurrentDnctory: !C .••••••.TLAB7'1work

a

add

b

,­mulll

"b

[34 5 6 7891

[222222212

56

1-10123451

» 0 •• [1 2 J 'I 5 6 7]:» b •• [2 2: 2: 2: 2: 2: 2);» add" II + b

double

double

double

double

double

,"" .

add"'o.+b!Iub •• III - b

ole8." [12 J 'i 5 6 7];b •• (2 .2 2: .2 2: 2: 2];eldd-a+b!!tub •• a ­

multl·a~b'dlv •• II I b

» I

Fig. 13 One-Dimension Arithmetic Operations

(Addition, Subtraction, Multiplication and Division)'MAll'" _ 0'1><1

» b - [1 2 3 4; 4 5 6 7; ? B 9 1]

b •

» add" •. + b

add ••

-.-7-1

o -2 -)-4 -'I -6-7 -6 -8

3

•10

» !Iub •• II. - b

)""M'"'B"I;

elea •• eve (3,1)b •• {1 2: 3 4: 'I 5 6 7: 7 8 9 1]add-a+bsub •• II - b

multJ. •. a • 1;1'

clellt"eleII •• ~V~ (3, 1)

b .• (1 2: J 4: 4 S 5 '1: 7 8 9 1]lldd-lI+b!IUb •• a - b

~""" ,

l!:=JWmFig. 14 Matrix Addition and Subtraction

Page 21: Dsp Matlab & Two Marks

Introduction to MATLAB • MAT·15

'MATlAIJ l-lll.I'lrxlFile Edit Debug Desld:op W\r'lckJw HaIp

D ~ l\l> iI!i "" (' •• ri. t c~, ••• or"" •. ,

, X

liI!11!":"'.1a.Ilm·.S1OC'"

~~~:~~~~"'=]{3~;~'~~',~~~,~~=~=~I}::;~-'=£E b <3)(4 double> double

Ell div 1-10165059259 -00740. doubl,E8 multi 11 4 7;2 5 8;3 6 91 double

» a •• eye(3,4)

» b •• [1 2 ;3 'I; 'l 5 6 7; 7 e 9 1]

b •

» multi" a • b'

dlv ••

» cl1v .• a I b

-1.018S

I -0,07<1

;~.: Q.8704'¥f,'

? » I

!1M •• eo - b

multi" a It h'c:ll!elX

eleIt •• l!yl!(3,'1)b •• [1 2 3 ••: 'I 5 6 7; 7 8 9 1]add"'a+bllIub •• a - b

cll!:arelea •• l!VI! (3, 4)

b •• [1 2 3 'I; 'I 5 6 7; ? 8 9 1]rnulti-sltb'd1v •• a I b ..,"

-0.07'110.03700.1181

0.59260,0370

-0.5185

'i"

multi ••

""""t',,,',,1;;+.

I MAIIAIt r_lrl11llXFie Edit Debuo 00","" """'" HoIp

D ~ l\l> lI& .' " ••• ri t C~""",,,,, •. ,,

ShortCl.is :.lJ How to Add ltJ V\tM!lI's New

double

double

» t •• 0:8

t •

» '1 •• e'-colli (tl

» '1 • t.*cos(t)

v •

Columnl!l 1 th.rough 7

0.5103 -0.8323 -2.9700 -2.6146 1.4183 5.7610

rnl •• b It a

clearelea" eye-(i,S)b •• 0:4

Columns 8 th.rough 9

5.2773 -1.1640

ml •• b "" •

m2 •• b s'

b. *a'b.ltsclearelet ••0:8SO •• CltCO!l(t)

V •• t. ·CO!! (t)~,

~.'\m:~.nll.II·I"I'III'I'I!I;;I•• I·I"I'I"I!'I'I·I·I••• IEI,••••••••••••••••••••• II·I··I·I'I'I·'.

Fig. 15 Matrix Multiplication and Division

Page 22: Dsp Matlab & Two Marks

MAT·16 • Digital Signal Processing

MATLAB is case sensitive: 'a' and' A' are two different names. The comment statements are preceded by

a '%'. M-fiIes are macros of MAT LAB comm. and they are stored as ordinary text files with the extension 'm',

that isjilename.m. An M-file can be either a function with input and output variables or a list of commands.

Basic Built-in Functions Generally Used in Signal Processing

v = [ I 2 3 ] % a row vector

v = [ 4; 5; 6] % a column vector

v= v'

v = [I: .5 : 5]

v = pi*[ -5:5]/5

v= []

v = [1 2 3; 4 5 6]

v = rand (3, I)

v=m(2,:)

v=m(:, I)

size(m)

v = zeros(size(m))

who

whos

Arithmetic Operations

2*a

2.* a

a/2

a.l2

a/'2

log([1 23])

Statistical Operations

sum(a)

mean(a)

var(a)

std(a)

max(a)

det(a)

% transpose a vector (row to column or column to row)

% a vector in a specified range [start: step size: end]

% [start: step size: end]

% empty vector

% a matrix: first parameter is ROWs and second parameter

is COLUMNs

% random matrix (see also randn)

% access a matrix row (2nd row)

% access a matrix column (1st column)

% size of a matrix

% create a new matrix with size of m

% list of variables

% list/size/type of variables

% scalar multiplication

% pointwise vector multiplication

% scalar division

% pointwise vector multiplication

% pointwise vector squaring

% pointwise arithmetic operation

% sum of vector elements

% mean of vector elements

% variance of vector elements

% standard deviation of vector elements

% maximum value of vector elements

% determinant

Page 23: Dsp Matlab & Two Marks

Introduction to MATLAB • MAT·17

FOR, WIDLE and IF

The general form of the loops are

(for, if, while) expression

statement

end

Relations

< % less than

>

% greater than

<=

% less or equal

>=

% greater or equal

% equal--% not equal

&

% and

%or% not

Formats

format short

format long

format short e

format long e

format hex

format bank

% fixed point, 4 decimal places

% fixed point, 14 decimal places

% scientific notation, 4 decimal places

% scientific notation, 4 decimal places

% hexadecimal format

% fixed dollars and cents

Page 24: Dsp Matlab & Two Marks

.................. :.;;'

MAT·18 • Digital Signal Processing

Plots

The plot command creates linear x-y plots; if x and yare vectors of the same length, the command plot(x, y) opens a graphics window and draws an x-y plot of the elements ofx verses the elements ofy.

1.1··:~l'~'!~!'~!1111.11.11111111I11 ••••••••• 111111111111111111.11 •••••• '.,,'.· £3.NtEdltDebugDellr.topwndow~

D"'~' -"""'~.'."" ;:~-,j--e1T t C~r" OhdOfY. 'C:·;w.:;:L:i.87~k· ..·

ShorlCl.f1 l.l How to Add lJ 'NlIll'~New

» )(-lin.!!lpillloe(O,1·pi.200);» V •• 1n(xl;

» plot(x.V)::>:> 1:.i t ie ~ ' :l i 1\' i,,):,,, -c ,,'f 'Jl ~. , ) ;

» ,IMe! (',..J)' '..1 );» x liU:le 1 (' _~ iy:,"':;'I"~l"I,~I ):"

Fig. 16 Generation of Sinusoidal Waveform

fII•• f •• ~~DP"~ .. !'tlIII;l",,.,.

D ~: x, l\IIB j("' ;'-, . " f!1 ,t i Cl.rrenlDnetory: ..~:.~~!\~.~

$hor1clA. !1J How 10 Add ~ WItt', New

:;y; ... frJ

» x-Unspllce(O,4·pl,2:00):» V •• ~n(x);» plot(x,'V);» title (' .'1j.Il·I.~,:;~'ll'.lv~V"'.t'(;I·~·):

» ylabel (' ~."" '.:,) );» xlsbel ('!' ,.,"",:"(H' -; );» hold ("n

» plot(x,co!ll(x). ' I:»leqend('t.'i.ne'. ·,,:'~ir.t.o');»

Fig..17 Generation of Multiple Waveforms

Page 25: Dsp Matlab & Two Marks

Introduction to MATLAB • MAT·19

The general form ofthe plot command is: Plot(xl, yl, sl, x2, y2, s2);

Color ColorMarkerMarkerLine StyleLine StyleCode

Code Code

y

yellow Point-Solid

mmagenta 0Circle Dotted

ccyan xx-mark-, Dashdot

r

red+plus--dashed

g

green *star

bblue ssquare

wwhiteddiamond

kblackvtriangle (down)

1\triangle (up)

<triangle (left)

>tringle (right)

p

pentagramh

hexagram

Fig. 18 illustrates the usage of grid and axis control.

PM, Edt Debuo o.sI4:OP wndow Help

'D"'~''',''(~, wa .• "'~,:~...';:~"'; ..• d' t :c~;~";~;~"·l:~::~!~~!~.~{····

» x-linspace:(O,4'pi.200);» V • s1n(x);» plot(x,v);» t:ltle (' ''In'~i!lOl,dl!1J. unve1:'ot:m'l;» vlabel('llln(x)');» XIMelj':, (r.'),,~j.~.•l,.~!)');» hold Oil

» plot (x, eo!!!(xl, 'x:');»leql!nd('.~,trJ"'·. 'l".'or~::,n~"l;» gz::ld or:» ax is ({ 4 10 a 1)):»

II)11 ""i'·· f1ATl •••f) , f J I •• I I< If ••~ 1 r r~

Fig. 18 Formatting Waveform

Page 26: Dsp Matlab & Two Marks

MAT·20 • Digital Signal Processing

Multiple Plots

Multiple plots in multiple windows can be obtained by using the command subplot.

_}Ul':\!F" I!dt 0Ibu9 o.fI¢op 'olMdow .HIIp

Cl ~ ~ ,t. ••• "., c.. • r! ! t CUfrel1 Otectory: :.S.~.~.~~~~ ....ShorlClA. ill How 10 Alld III WI •••• New

» subplot(2,1, 1);» om" loO'.pace(O,5,200);»h1&9''' 20·1oQ'10~ab5(1000./(1·0tD+I000)l):» IlIl!!ml1oqx(om, ll1agl:» 11)(18([10,10000,-20,5]).» Q'rlcl'.m:»11ab.l(·'~{,H.i".lhi I:» j(label (' ~'r:'"'-'i1'':'''<:''' • '-,.}i' ) J

»tltlel',I'Jtl~ pW( ,rr',,"q:n~u,I¢"J;» subplot (2, 1,21;» rlld_to_defiJree •• 31501 (211'pll;

'» pha.e- ral1_to_cleliJree·.nOl. (1000./ (i ·om+1000) ) ;» .elllil00'x(OIll,pb •• e):

» 1ll)/lsl(lO,lOOOOO,-90,Sll'

» grid l,r,;» V1abe1 (' b.wJl<"! iI.i~';Jt·t:.~)' I;» xlabel (' tr:t~qw:'r".'" \ 1:<l'J.',~(:';~I ) J

:» t it Ie ( , ;'.-).-1'" ip)"l:~",: ' ) ;"

"'fe"f

Fig. 19 Multiple Waveforms in Multiple WindowsGeneration of Waveforms

ElI.I!!mWim~t"i.li!",i!';!!,!Iii':,F" Edit T.xI CtI ToolI C\IItlu; o.lktop wndow HMI

D "" Il ''I> I!II. on ,> :. : ,. f. iii i!I >ill111\W lb l@ ~ ••• :

,.

1'1•• 0: l:N-l:

1(1-co.(O.12-pl·n) ;IIw:oplot (2,3, 1) ;.eelll1(n,xl,· JI'):1I1UJit1 (' '1') :'i'llll:lel(' }'lil'!");tltle(·I'n.~JurH1,id,~J,;);lIIxll1([O 2S -1.5 1.5))::, 'j') '• .-"w;nH r: •.• I. ).,'J 1,1",' "'y'~·~'t"l!,-r

)(2-1,2. ~ (1'1) ;

lIubplot (2,3,2) ;:lItelll(n,x2, '1••. ):1Ilabel (' TJ'I :vlabel (' x;:[n)');

titll!('L~.;)i,1'.I ',x~<..'J'~,M:''''·I:eu'i.{[O 25 0100]):" '1';, .~"",·,"'r:':l.','1' -'!l '.iI",'''\' ",xT'Ot"l-rt'l'.' "::, l'Jf!",lUI'J\,~'"

x3"0 .$5.' ~nl:llubploe(2.3,3) Illtelll(n,x3,' v'):x Illbe 1 ('II' I /ylabel(' ldtJo!'):tltll!('rl"'~''''\, "xT",n"'nt,' ••~ );axll1«(O 2S 01,5]):

x'i-on •• (l,N) :lIubplot (2,3,4) Jllt4Ull(n,x4, 'k'):Klelb.l ('I,') :solelbel{' >,,<lrq '):tltle('~wi~ 1'It.':':i")al<18([0 lS 0 1.5]);

•••••10:1: 10) IrS-rillll\ll:)plot.(2,J,5) :lltelll(lII,y5,' k');Klelbel (' n') ;yl-.tl.l(' I(~(n;'):tl.tle('nOlnp') :aKl.({O 12 0 12]l:

a--10: 1: 10: 'l'6- [leZ:Oll (1,10) ,1, 1ero;s (1, lOll ;;lluklplot.(2,J,6) :1It.t!m(ll.v6, 'p');Klabltl (' ,,'); ylabel (' :(~i,l,j');t.lt1e('\""~jul"''''I;aK111((-lO 10 01.5]);

) fj~url" '_Ir'll'x

Fig. 20 Waveforms Generations

Page 27: Dsp Matlab & Two Marks

Introduction to MATLAB • MAT·21

Plot of Frequency Response of the First Order System

Write a program and plot the frequency plot of magnitude and phase of a first order system h(n) = an u(n)where a = 0.6.

t""'H 1 r•. iff"" fx"'fd"""InMrtTailIi~~fiIlp

DiSg."~ ~€U"@ '" Dill ~D

f;1M.,~l~mf.HmN.j¥J&.L#['§¥lLl;"I'Illi ~ Tht ctl took DebuO··o."-' WI\dllw ••

D is ., ••••• ~:;j' ••f.· ee·m I!I! i!l,i[J ll!J , ••• r·:1 • fHl'.;;ll)U.cy~''''.~~~'I,~'''·"t '.1'" .~'I"'~"'l',-J. b"(l}14- .-(I,-O.'ll5- n-O:O.Ol:Z"pl;, h-tr eq I (b, s, n ~:"1- lIII1.lbplct.(Z,l,lj:e - plot(n/pi,alI.(bl. 'It,) I9 - lflabel(', ,,,.,,,~,.;t."'.; <r""F'~"'~~;'):

10 - ,label I "na'JlL" ;,.1, ) l11- titL"I" I:';"'.,u'l"m~"i1.·',yr';<lCft');12- •.)(ls([0203]1:13 - subplot!2, 1,2);14 - plot.(n!pl.anql.(bl. '1',' l;15- dllll>ell -"jl

16 - .,u,bel('"Il,,, .••' ):1'1- 1Il111a((02-11));"

••""XfIl [l)s,s,Ti:i

{~;--~a 0.2 04 06 0,8 1 12 14 1,6 18 2

norrn.lil.dfrequeney

1~C21o 0.2 O' 06 08 1 12 1.4 1,6 1.8 2

normlliz.dhQu.ncy

Fig. 21 Frequency Response o/the First Order System

N-point OFT

Write a program and plot the frequency plot of magnitude and phase ofN-point DFT.

rrequ'ncyresponn

00

"

~:1 irk hf9 frihol_~~_~ ~_~ __ ~_~o 5 10 15 ~ ~ ~

nOfm.hzedfleqll.ncy

.'f,urrl r.!'"All Edt \IIIW,in..rt ToiiII DtIIIcp, ,..... ~

D~g.:~i'<!l.El.O@ >ll'!,OItl ~C

l.')1

, ~',n'lUl co,1; l>r',

'.",-',n

xl-[xn n:ro:l(l,N-L)]; \"""l'ljnl)

)1-32;)In" [l ~ 3 4] IL " lenQthixn);It(N"L)

er ror ( "; 'Co':,,",~'

tM k-O:l:)I_1to~ 0-0: 1:N-l

~••.1,U.-.xp (-1-2.p1-n-~NI; :,'_,~i,ll~- /.'J.I.'f',c,t' "·'!;:ll'.H'r,d(k+1,DH)-t"'1dh:

h-IlbS(xlC);

p-sn'O)J.e(xlC);

k-O:N-I;.\lbplct(2,l,1);.~elll(k, h, - 1<');xlabel( ''''.;t';""l, ",-,,1flabell' : ~ (•.', '):~l~l.(' ,tr("'\l<''''''''' J.-'.',

.xl!O«(OJ10 12));8ubplot (2, I, ~) Il!I~ell\(k,p, : ", I;)llabel('r,':'~"'?:'."" h"~'1""""":I;vlabel (' l'~,,',.~r ,,-,,,-, I;sxis([0310-611;

fflZill"'~'ill1~1,'!!~f1!lt,n!lle!!!!!i!!~!\lII!I:"!J!IlIli!l, ~l:i!IJ!I!!I.I1I.~§t!;~li!!i •••••••••••••••••• 1II ••• 1II1II'1I'1II11'••••• Ell: f.id CIlI fodli DIlIl.iO' 0Mkl. 'wndr/w '.-

[J1lJ.1I.,* ..."' •••...., ...·.~ .011."f,I'l~~~'?I[J.'I!!.~T:::::::,,­,­,­,­,­,-.­,-"

:11:12­(13­,,­,,­u­n-",,->O­

n­,,­n­

:2<1­~u-,,-,,-,,-,,­30­n­,,­,,-

''''Lit ..·,,, COIl'

"j$rart )'''01' I'.'" ;'~.I,."l',h lei k"~. "

Fig. 22 DFT Calculation

Page 28: Dsp Matlab & Two Marks

MAT·22 • Digital Signal Processing

N-point 10FT

Write a program and plot the frequency plot of magnitude and phase ofN-point IDFT.

Kk·(l0 -O,1142-'L~426i -2+21 2.4112-1.21261 -2 :Ln12+1.2426i -2-H -0.414<:+'7.24261J !N·lenqtli(Kk);

1,­,,­5­6,,­0­

lO­

u­u­u­13­

15lO­

,,­la­

10-" ­11-

:-'\11'" ". ~I." T,',\~,l '.1,1,11 t. •.•,·;r'~~·to( n-Oll:N-l

tOt k-O:l:N_l

tw Idlc·cxp (-1 '2 • P1"0 'k/NI : ',t. '.".dic .t.Il':·~.~,r'~..:r'I·:·'~'~'~'f,Xl (n+l,):+l)-tlll'ldle:

•.•nr!

Ko-(xk"xl'l./N;

n-O:N-l;.tem(n,xn, "0');

xlabel(' ,.,'j:TIMe!(':,·,,),):tittel'in'''' .•,:",,,,,",n I:.K18([O 6 0 5)1

I j~ut~ 1 r'•• I [j 'XIRit E4 ..•••• Ihse;t fllllil DtlsktOP Window ~

i:i~ii1.::[':<il.e. fi~!·.jl,tj[j "El1r\'Wtlu OFT

45

35

15

05

Fig. 23 IDFT Calculation

Circular Convolution Function

iJI f dUO! (\MA II AH'\wolk\!l~r book\r wn'l In f: 1ri5 If)(

Nl·lenqth~l(n) ;

N2·1etltJth~hn) ;

·<';lr(~lli-u: (;('fl'l'lilJ':l(J:, c.,t 1;,;:0 ~"!que!m;e!l

tlJ.nct1on[,J ·cconv (xn, br\.NI·,S··..,,~'\H;t'lt. n',"j',,"n':Jf

~ '';IN "Pt",.·, !I') Tl'.:~

1I"'[Kn ~ll!I:o.(l,N-Nl)l; ';I"~'IJf, ..IH.l ~,"~!x<"n'-;, ','. ;,/;j'''.:t. 1",,,.-,,d

h'"[hn lero~(l,N-NZll: ',,";'l,~'n'~,~;;,tli\ 7(:r()':", ','" ;,mp"l.;:\'; cr"rJr'OI":.

m-[O:l:N-l] ;K'"",odl-IIl,N) ;

h"'h(!+l) :tor n-U l:N

",""n-1;

p.O: l:N-l;q-fIlOd(p-Ill,NI;

hDl-h(q+l) ;

Bin, :)-hln:

••• Edt Text C.I Tool~ o.buQ DMtop WIndOw '"'*' 11 : ,. :lC

D.~Ili ..!·.ii!l~·..""-'."' ".·..i.·. ·1iJ·~.··.·;~~~'ltnilm••••, .1,J

•5

6,,,­

lO­II12­

13-"15

lO­

n­10­

19­

zo­

21­

2l­

2l­,,­Z5­,,-

Fig. 24 Function of Circular Convolution

Page 29: Dsp Matlab & Two Marks

Introduction to MATLAB • MAT·23

Circular Convolution

Write a program and plot circular convolution.

"'.. I!. Text eel fooli DebuQ OftIrtQl) WIndow H8Ip

D~.··)ilt.··;;;';."t:fii~:;j_jtDjj,-1',;,..' II X

......................·····ijjms;,[g'1 ',,'·.\r'.".\,\~,r L'OI','.'(J,lll( ',[HI '.If t,~¥:".' ~j""q'H~W_'("~2 - cle.r ~.l.l3 - ole'I - N" 4:5 - n-O:1:6 ;'11''''117 - 1I1Jbplot(Z,2,11:a - xn-[l" 3 1);iI - Nx-Iength (xn) :

10 - n-O: l:Nx-l;11- lItem(n,xn,'}(');

:12 - xlabell'l\'):vlabe1{;",(nj);:13 - t1ele(";l"lllUt jli'_:Jll(~1');Ill(is([O 'I 0 5]):"

15 ",:i ~\'PU:.tIll r~fll:-(·mm .rfl'qlHr.r:(~

16 - sUbplotIZ,Z,Z);11 - bn-[Z 2: 2: 2J;18 - Nh-length(hn):151- n-O: l:Nh-l;20- .eem(n,hn,'k'):21- xlabel("!');V1abe1{ lito] ,);22 - title('i7l.'pu.\~<!': r.~!''P(Jn.~~.'l;axil!l((O 'I 0 5l);

:ZJ - It (N -< max(Nx,Nh))24 - error('N nn,l.~'tb~: qr.f:·1I.ter '~r. :!:quni ~(~ml.;4(:Jx,1'J1'l) ')25· enct"27 ~ ': !1:CUlo!'lr ':':'ilV(·l.'.\'.: i')ll

'IS - yn-ccol\v(xn,hn,N);HI· n-0:1IN·1130~ 8ubpJ.ot(Z,Z,3);

':31 - n-O: 1:N·1:32 - 5tem(n,vn,·I<.;~;

33· xlabell'~i'l;y1abel( \'((\1 );

34 - tl~le('c':1J:(:ul~l: ,_~rjllV01'.I':i(m'~I.xl.([O 4 0 ZZ)l;

_:I i"p~;i9"~ r _ :[ impul•• "'pao"*~WL~l~lL0123401234

"circular corwolulion

Fig. 25 Circular Convolution

Page 30: Dsp Matlab & Two Marks

MAT·24 • Digital Signal Processing

Linear Convolution and Correlation

Write a program and plot linear convolution and correlation.IJI!I.'''I.IilDII,'''m!!!·.!'I,I!if,II'lftll'',i''-'d'JI,'I;I'll [dIt T.xt CtI TooII DtbUO o.tICllP Wlrdow Help

Dail., "~ • ..,,, ,e'" f.' flItl"._fI1l1i[ll!\l'''''''[''

'...•i" X

£I:IIllSl'il'.R

1"Ii£:l:,Yitw'IrRttToaIf~,"'Wlridow~

Daillile'.~ ~E1.~:!).I{' IJI:jJ"D

"corr.I.lion

"lintarconwlulion

·~w·~co 1 2 3 4 5 0 1 2 3 4

1 ~ 111",,,,1':' ""en"',',; '.,~ ".'/1 ':It: t••••.:, .'l:I"r'",r].,:,,'!l'

2: - ele.r ~.\il:3 - N· Il;,,- n-O:e:

;.!i ~i l':pl, '._ :~",'-l';."'1

6 - IUbp.lot(Z,Z, 1}:7- IIn"'[1 2: 3 4 5J;l!l - Nx-lenllth(xn);9 - n-O:l:Nx-l;

10 - Item(n,xn, ~- I;11- xlabel('(;'))ylabel('x[r,j l:12 - t1tle(' lr.,.'" !<".I:',~l') ;axllll0 5 0 6) l;"14 - lIuklplot(Z,Z,;n:

15 - hn-[l 2 1 2):16 - Nh"'length(hn);17 - n-O:l:Nh-l;ll!l - stem(n, hn, ~,' I :

19- lllabel('n'):ylabel("J\{n.1 l;20 - titl.('ili\p'i.J.u,~ ,.'.~:;pc,nrJ",');axll!l([O" 0 6]):

~2:1, \ l1.nl': .•r. ,·:I.'I;':I'.';.U~.'H,fl

:22 - .ul:lplot(2,2.3);'23 - ,t"'convlxn,hn);]Z4 - n."'OItINx+Nh-2;25 - etem(n,Vl,' '"" I;2ll- xlabel('r,'):vlabel(''1[rJ] l;27 - tltle~' lin-" ••. '_'UltV'."',";,i<,>f");llXls([O 8 0 22]1;ze ;l.,ir:~~t' r_,(;r.'."_~'\l::,i'.H,

Z9 - subplot~Z,Z,4);30 - vZ-xeorr (xn, 1m) ;

31 - n-OltINx+Nh-2;3Z - et.m(n,v2, ')1';";33 - x1abe1('1~ ):yllllbeJ.('v[n) l;

34 - tltll!~";',",I-d-~t'L';h'I:.Kll11«(O e 0 22));

Fig. 26 Linear Convolution and Correlation

Overlap-Save Section Convolution

Write a program and plot overlap-save section convolution.

'Li'L~lo 5 10 0 1 2 3

"oulpu!signal

~:lA·""20

10

o 5 10

1\r,lJtc1 "••. '1:1 [xl•••• [(It VlIW JnHrtTOlils Deiiltqj WRibw', HI~

6~iii.} e:E1. fi~,jiio iG; •• c

Nx"'l.ngth(x~ ;II-len;th(h):Kl"'X-l;L-N-!l;1l-(lIerc.(1,II-tl,ll,lIeroll(1,N-1)] ;h-(h ler"oll(1,N-Kq;Jo:-Uoor l ~Nx+Kl-l~ILl;Y-lIenlll~K+t,N) I

.n"

Y-Y(: ,l'l:N)';

V·(V(:»)'

1IIIWPLot ~2,2,3) ; n-O:1:Nx+Nh-l;lIItelll(n, V,' ~'l Jx!-.t>el (' n') ;1'labe1 (' v[nj '):t_1tl,t!,("''J.~'Y_'·r,:,j,II\'" 1 ); e.Il,l,lII.U.O",~~,,~".~.OJ) I

~tiJJi~llmJlI!~B'II=!!gtlU1jYaI$iWM~\lI!M~;~'~!!l~!I~'~'~$.~~··~!m!I!!~L~I=i!•••••••••••••• III.II.II•••••• I'I'IE:I'•••• f:dtT.dC •• T~OeblJQo.Ptl)pWi'lcXMHIIp "'''x

Dail• , ¥ "' •• or> I. e," f•. e tl i ill Q!II! i[lliili ••••"!':';" e1eai:;-"T'i; de3 - N - 4;

" '< 'I :'jl,;t, ~"'1'-I"'I":,·

5 - lIIubplot(2,2, 1);i5 - x"'(1 2 3 1 5 IS 7 e 9]:7 - NIl"'length(Il):8 - n"'O:l:Nx-l;

9 - nelfl(n,x,' ~,.) :xlabe1{' r.') :vllllbel (. :-Ilnj');10 - tltle('in~'u'. ,"!;,;lr,'A,"'l:llXl:1([O100 9]l;11 IIIIl'ld"12 - llIubplotl2,2,2):13 - h"'[1 2 J]:1't - Nh-length(h)J15 - n"'O:I:Nh-1J

16 - lIItelll(n,h,' 1("') :lllll1bel('r:') ;1'lebel('J,[J'<]');17 - tltl.~'"I:\\pqJ,!,~ \·'1'fll-H.,n:HI');ax11l1([O J 04]):18 - i.! N<hnQ'th(hl

19 ~ error (' ti mln" ,'",' '_;I.'(,,-U,"r. '.'11'''''.( - J.,n-'-"-.!I '.'l' l,{ ,,] , )20­2l-" ­n-Z1­,,­ZO-"l8 ','.i,\"'~i.1~r,'.d t·,~,~ ~'1',~:.t~t\,.;~ UW_'.'

29 - tor rOIK

30 - llk-ll(k-L't1:k-L+N):3t - Y(k+l, :)"'ccOnv(xk,h,N);n­)3­,,­35­,,­,,-

Fig. 27 Overlap-Save Method of Section Convolution

Page 31: Dsp Matlab & Two Marks

Introduction to MA TLAB • MAT·25

I'g"'''' '... ~)(

1~ri i ---'l mmla 02 0.4 0.6 o.e 1 1,2

l\o,m'lindfrequ'rlCYphu.resp0rlSe

•• ~ • II(

ESCDS1l''IJ

magniluder.sponse

iII.!lI ••••••rriMrt.·T:ids··~Whi:IciW~

i)·.·,..··.l;Ij··(§Jl$.€l.·.·.t?ji·'·~·:·!fG ·;>··C····

1 \ """",<)",-..t,-.

~ - cl'.1: ,u,;3 - alphap·Z;1I1phIl1l"'Hi:4 - :l:p"800; t."lS00;$- r'"5000;,- "p·z~tp/rl "''"2-tll/r I

: 7 "lj~ '.";''''1.'.':':1.(","4',.,,:,,.-,\' <"ml '~l'(]<!,,'

: e - [n,vn] "buttoE'd(vp." •• alphap,1I1phIl1l) I: 9 :'~"f,H.<,·n'{,"""_, ,',(' t,;;'"

:10 - (tl.a] "I:IUtttt (n,vnl; \ tL~~~ (',;.'!f!"";''''l>':11- ,,·OI0.011P1/:12 - (b,ollllj "tl:lIql(b,a, v, , ,/l"'h'");;13 - Il'I"ZO·loql0(.m1lIhll;

:'14 - IIn'il".nqle(hll15 - lIu1:1ploeU,l,l); plot(omIpl,m): grid '.'r,;U - xlablll( ,,,.,,.,,, ) I17 - , IIlb.l ( . '~".>!, ,\~, <I(;, ) ;111- lIlli.([D 1.2 -300 SOll:l'i1 - ticle("nH;JII'.'.'.llj,. '-'--'l'(.r:."-')I20 - .Ubp!Ot 12.1.2l J plot (OJI'l/pl,angl; grld 'n,)21 - ltlMlt!l (' ,,')n~';J.,'~"l' "",''''1,,',,",":';') 122 - ,1~,,1(;VL',,~.· :"'i ..""·);:n· IIlt1.([0 1 -4 4));

i24 - tltl,,(;pt,""'" "":'I",,"",,'ll"

Overlap-Add Section Convolution

Write a program and plot overlap-add section convolution in your lab.

Butterworth LPF

Write a program and plot magnitude and phase of Butterworth lowpass filter.gtl_~!'Ii"!_'"13I!ilmrl'I'I¥I'~"!dI: T••tC"TodIOIitlUIloMktql~',~

ll,",ii1"'".n",.i"'. illlil''il'lhir

~O 0.1 Q2 03 Q4 Q5 O~ 0,7 me 0,9rlOtm.lindfrequ'rlcy

Fig. 28 Butterworth LPF

Butterworth HPF

Write a program and plot magnitude and phase of Butterworth highpass filter .

• ··::ullYJ-np,"'m-u'I.,Ph !dIt T,d: c.Il Todl DIbuIiI o-ttap wnb'I 'HIlp

"'. •••• n "1.'" f., iJlill'il'l'ilfil'i1Hi

IN":11 II(

IBCD S 1I"i::l1 '; "~l'.l'Jr, ,'I; ·'·"\\·'.<:'~.'f~'~,n,l{!'Y

2 - olear,:, ;,~:3 - a!phap"1;a!pha'-30:• - tp-1!lOO; tll-eoo:S· '-5000:6 - vp-2·tp/F, Wll~2-till';., 'a, ..f1 1''-'-''1''''-''-',' '<:1'1 ,..I,j", '-,1' LI·,;·!l - In, wn]-bucCO[d(wp,lI', .!pn-p, alphall) 1iii t!':.'''.~'" .t:::"T:;',~ ,~1:~,l'~.~li;'~\"

10 - (b,.]-I:>\lccet"(n,.n,'"',,,.~l;'); I;j~'.'fr,·'·'."'!:1.::l,·;it:".·

11 ~ v-O:O.Ol: pl:12 - (h,olll]-t~eq3 (b,a,.,'- \,t, .., I••' I;

: 13· m-20"lo91O(U.II(hl);1. - osng-.flQ' 1" 'h);

'115 - llYbplot(2,l,l); pl(>c{om/pl,m)1 ll~ld ';"116 - Klu.el (, ",.. r"", j ,,,,,1 f ("'~"'·:!":.:v· ,;11- ,1al:llt!(''<I'.lln':r,cJu·j:18 - axlsl[O 1 ~300 50) l:HI - tltl.t·l\'" ••••·:..;.~."',it: r,<y(-'.,r'!I(/" I;;:0· .ubplot (2,1,2); plot (olll/pl,ang); 9~ld ne,;21 - xlab.ll' ""''-1<'",'i ,,,,d .1' ••",\",;.,,;~,; l;22 - ,lu.el(' ,.M,',','· "!"".i.,'~r.');U· OSltU{[O 1 -4 4.])124 - t1tle('~, ,"'W ,-",'>'p""''-''');2S

1111-'"'' 1 f.•. Il':'; rxI'illIEdt .•••• ·!nIIiIt·T_~:.:~·:~

ll,",ii1./~',iil.e.(>ji> ~'tilijil.LDm'gnrtud.r"pgnt.

~1~[~~-:!;~I;--~~i'. " : : 1~:L.:. : ..;--..,' 1.. ,. ; .° 01 02 03 0,-4 0,5 0,6 0,7 0,8 09 1normalindn.llu,ncy

ph •••• uporl"

,-40 01 02 03 0,-4 0,5 0,6 0.7 oe 09nOl'lTlaliZldfl'lqulncy

Fig. 29 Butterworth HPF

Page 32: Dsp Matlab & Two Marks

MAT·26 • Digital Signal Processing

Butterworth BPF

Write a program and plot magnitude and phase of Butterworth bandpass filter.f#I.M"i,n,ns,re.::'INi.j'M"I!I.,.el!

,... !eM "lit ell ,. ~~1IP ..".. •••

D""lIIi~.;;;: .,.i;Qiii;e_.:i(iijji _,',

.••!" x

iliirii3~;gel •• t' ,,~l:alphap·Z;alphall'"'ts;:l:pl·400: tpZ-UOD; ral'"ZOO; ta2'"1800;'-5000;• p·[Z·pl"fpl/r, 2·pl·fPur]:vs·[Z·pl·tsllr, 2"p1"(5211):

~ ~1 Q2 Q3 0,4 0,5 a6 OJ 0,8 0,9normlliZldlrlqUlncy

magniludlrlSponll

·;tJ~Hfn~ttjim= :_-'_, ' ; :.._~.3)) i ·· r" --T····· T······ [ r···· ..:···..·..·~······1·····

'°0 01 0,2 0.3 04 0.5 0,6 0,7 (J,B 09 1nOl'fYlalizedtrequlnc:y

phlnruponll

••••·-tdlt_liWt TooIt~,1lItdcIW _

Df;i;~.,~''''E1.l'!)~)1ie: [JIG "OJ

tltle (' l'~"~"'" ru "'H',,-,,,,'I:

""''7'1\",,," :,,,~,.:t. ,:,',n -,1

[b,a)-butter(n,wn): ' t· ,nn' :';r.l".~?:,\',';,""<

."010.01:pl:(h,om) ••tceqll(b"a,v);_20"100;1'10 (abll (hI) :8""'·.11.,,18 (h) ;s\lbplot(Z,l,l): plot(olll/pl.m); QUd m;11label('1lI',1.1"'''':.': 1"':.1 ~H.q""'''",,'1'):,label! ·.~n1r. it: 'J[;');a.ls((O 1 -400 50J);t ltll! (' l1"I':\~l,o.J !.''''.1" ,,,,,,,.,,_.n,,~');.l.Ibplot(Z,l,Z); Plot(oll'llpi,aIlq); ••riel ,Ii';Mlllbe 1 j . 11,,1:"'" ! J, ~",l fr,', '."J"~'~'" I :

flabel(' r')'''Nf'' ;. "<1,1;"" ):aMls(IO 1 -4 il):

1,­,-

i 4 ~,.,­7e-

: 9lO­u­

,12­i13­~14 ­i15 ~:16­:17­"18­'19­lO­

ll­,,­,,­H-"

Fig. 30 Butterworth BPF

Butterworth BEF

Write a program and plot magnitude and phase of Butterworth band elimination filter .• _I!i!!!!r~."IIII!a®ltllID"M IUmFIe Edit Text eel Tools DebLJGDMlr.t:opwr!dow Help ,.; II X

[J ~ lIli''!loll'&0':.' "i~:in:'!il~!IItlllll!a:."":' el[D8 6'Q

IJr.ur~' t ••• I:","IX

magnituderespon ••

o -1, ;t.:.:;+~ i -I

1:13:11o 0.1 0.2 Q3 0.4 Q5 M 0.7 ~B 0.9

normalizlldfrequllflcy

IJ~rf~o rr1 0.2 Q3 0.4 05 0,6 0.7 O,B 0.9 1

normaliz.dfr.qu.ncy

1"k~""~>i'cKiOliSltcp'llMlbrl11llp

o i# IiIj;'~iGi:e:~~tltfli3iii oj

cl •• t" foIl.;

alphap-Z; alph.s-iS:tpl-Z00: tpZ-1600: tsl-100; tsZ-1200:r-sooo;.p-[Z"pPtpllr, Z·pl·tp2/r);ws-[Z.pi·:l:sllr, z·pp:l:s2lr]:'.") l'in:1 t.J\t: "",'.';I..t .t'\·:'n1"'t:I~\::O''''\":'1 ,.,\·:'j~r ·)1: t.j\~ j;1.l.t,~~·

[n,lIn]·buttord (wp/pi, .S/pl, alphap, alphas) ;

(b,lIIl.butt~r(n,.n,· •.•..)r-'); ,; :t'~;"~C (...')~1'tH"~nlII-O:O.Ol:pl;

!h,oml·tr~q' (b, 1II,II);m-;W· .loQI0 (lIIb5 (I'll) :

snQ-snQle I h) :

!lUbplot(Z,l,l); plot(om/pl,ml: Qrlel !)n:xlabal (' IF.~l:1<'!~).j, M!,jh'~q\<!:!r,r:'l'):vlai:le.l(' t,lHn,I' "U');lIIX18([0 1 -350 SO]);

llubp.lot(Z"l,2); plot(orn/pl,ang); qr1dI(labe 1( , n"u~·:d" ~..,t! trt;.-1";~""::~' ) :

flabel (, pl,'t,"r L·,~(j',(,;;·):

.MlsteO 1 -i i]):tit 1" ( 'p),ll'''' t:'! .':~,,~•• :,::,! ' ) ;

1,­,­4­,­,­7.­,lO­

ll­,,­13­14­

15"lO­

17­lO­

19­lO­

u­u­,,­,,-"

Fig. 31 Butterworth BEF

Page 33: Dsp Matlab & Two Marks

Introduction to MATLAB • MAT·27

Chebyshev-I LPF

Write a program and plot magnitude and phase ofChebyshev-I lowpass filter.UtlfW':I'I!{mmrnmm=n"r'lIlItFIB f:dt Tut c.. fa o.IJug Desltap wndDw •.•••

D oi'IiIIOloik., •. " f.I!l~"lIJ(lj'llIltli.9"" .

unlli"llC

.. ......E!1Il1§!/jl;i::l,1

: 2­,­,­5­,­,e­•lO-u­u­1J­14­

!S­16-·n­10­!O­lD­

'1 ­,,-'1­" ­"

~ ;"r:",~,;m 0': ~1~e;~:I~hr:v,·rclear ::.1J;:

•.lphtip-2;.lphu"45;tp-eoo; t.·leOO;'·5000;vp·Z·tp/r: •.•·2·t.I':

[b,aJ-ch.byl(n,.lphtlp, •.n): \ til,U'I"v-O:O,Cllp!:[h, oB1j-:tr@qz(b,a,v, '~'h:.' 1-:' ) ;1Il"20tlogl0(till!l(n)) ;anq-anqlelh) )lIubplot(2.1, 1); plot (om1pi,ml; orid mlllllabe 1 ~J l''-,nl''~ 1''''''1 l',-'-,c.p","I",'; I;,label t· ';'''' ;:\ jl~ di': ):uUnD 1.2 -300 50J):

lIW!plot(~.1.2); plot(omJpl.anq); qtld on;x lal:lll! 1 ( . 'H.' !err'" 1 ;. '1:"'.-1 1.r ~-'~,\lf' ',",' 'r ' ) ;

Vlab •. l(;r~J,,"I'<'" '" ~·(\'<;.~r·.·):IIK1SHO 1 -of ill:

••• !~..--lnMrt'TOOlJ~~·""

D~Iii."~"<;i,e. fl·~·.··~··.·d.~. "[J]mlgrlilIJltef8llponse

°t·····_· __ ···",·_-_···~!'···········:,········:i·······a··1100 .. _._-_ .. _....: •.•~-.~.~:=~'~~~.!~~.200 -_·_--·--·r·--··-_·_--~·······_···i···········;··'···· .';lOO --~--~--~-~-~° 0,2 0,4 0.6 0,8 1 1.2

normalizeltfr8QIJ8ncy

I:t ..·..·:....·.:....·~.i.;1·~·.. ':lc"':i..· ..j ..... l lS· ...i: ~~f~~J·T::CT1 r : ..., -~~~~-~~~~-~-~~--o 0,1 02 03 0.4 05 0.6 0.7 0,8 09

nOrlTlalizeltfrtQlJsncy

ij•• !E-t;i;•• 7.'T••·."'.'~!

Fig. 32 Chebyshev (First Order) LPF

Chebyshev-I HPF

Write a program and plot magnitude and phase of chebyshev-I highpass filter.

EI.L~~._.mmtilil"" Edt Tlffi eel Tools Debuo oesItop 'M'IcIowHIlp

D~ili ;.•• !ill';.. "i. 0ii!1;4~ljjiJi]1III ••••

'E... E1Jmi3ii'iJ

1 ;)'~,"~.,;l,:,1 '.:J>i":' ,'.It,bl·' 1 tiP,'

Z- cleat ':\),,';3 - .lpi'lap-l:alpi'lu-30;4 - tp-1600: ts-600;'-5000:oS - wp-2't.p/';"sa2·t~/':ti ,..',r, •.)f~ r""',F"""7 - (1l,Iol11J"ch~blotdC.p,ws,lllphllll,alphu);8 f.,,,,I.'l'i,'-,1\

9 - (b,a)-chebVl(n,alphap,wn, );10- v·O;O.Ol:pl:

11- [h,oll'l}-treq;(b,a,v, ·"~:("'~'l;lZ - 1lI-,O'loql0(Mll(b)):

13 - anq-anqle(h):14 - subplot ll, 1,1): plot (OIlI/pl,m): qrlcl ,~:\:IS - XIMe 1 ( . 11,'". ,o,c\1 ~ ~~<,:j'f.f,'(:.; ,(, .11":';' ) ;

:16- vla.belC·'.I,d"i;,dB'):

:17 - a)(I11((O I -300 50));HI· title I"""::'iJ "

'151 - subplot(2, 1,2); plot (Olll/pl,ang) I gnc:l ,~a;,0 - xlabtl ( ',·.,~t';'$J.'.~~-:l.i'\'<,wvt.:J':'J');

21- yla.bel( ;,I'.,;fji: ;,1,\"1",:"''':,'):22 - axi,,((O 1 -4 4)):~3 - title I' "'.~"~:(;<:u,,~·r,.l~,');,.

I'lItEdt_InMrtTOds·Ottkop~ •.••

9~1iI~:};:@,e,\")~'li!'O~ .~ CJmagnillJderuponst

t·I·······'1"········ ..I· ···:···i·~! .• 'I ~i:rtfiI~H····i····i.·..'....j° 0,1 ~ OJ 0,4 0,5 0,6 0,7 ~ 0.9 ,

normalized frequency

!:i·.·.····11ic···':·I,' ..·;,=·]:li'jl".s--,,·j.~2·: ....·:··..·~..··T:+~···T·"T···4-~-~~-~~-~~-~-~o 0,1 [2 0,3 0,4 05 ~ 07 0,8 09 1

normah.ltfrequllncy

Fig. 33 Chebyshev (First Order) HPF

Page 34: Dsp Matlab & Two Marks

MAT·28 • Digital Signal Processing

Chebyshev-I BPF -•• ~ " )Ie

iHrnB6'p

magniluderesponse

"'~r>?I·····~I:·I~···········I········~~1 :1·:+1 ;~I··~I·····l·i·~••····i·uu.':..···,······f···· ··,·····,····,······i··~.·DJ ~ ~ ~ , '!-, : ~""":"""~""" .~- -, ~ ~·«DO 0,1 02 0,3 0,4 0.5 0.6 07 0,6 0,9 1

nOflTliliz.dfrequ.ncy

I~t~Sf~1Ii i ]a 0,1 02 03 04 05 0,6 07 DB 09 1

nOlmaliztdfrtlquency

, •• !cl YlIw InHltTooI5~ wnkM •.••

DCli'liI ••. ~.. <lI.E<~~ If O~ ~CJ

tit 1!' (' ""~'.lr..J,".ud"

'Ubp1otI2,1,2): plot(OIllIpi,ang): grid ~I,;l! lelb!'L (' ,,,,\ym~l,, \ r,,'j :J:,>,'j\h"1 .~,' ) ;

ylMel('r-"l<.,~ -,f, re<·IH,n'):

axu([D 1-4 4Jl;title l' ~',\tn~l·~,~.'a,~r:'):

[n, vnj-cheblord ("p/pl, vlI/pi,alpnap,alpha.);.•..'yr.'\"'·"~ t'.l::~:';\~..l: ';.! ';:"It 1'ilu,r

[b,aj·chebv1 (n,alphap,vn):v·O:Q.Ol:pl;

[h,ol'llj-treq;(b,a,wl:m~20·1"ql0{1Ilb~(hl) ;ang-angle(h) ;lIubplot (2, 1, 1); plot(OII'I/pi,lllj; qrid 1,;

Write a program and plot magnitude and phase ofChebyshev-I bandpass filter.EI'.~"~'l,·!~,mIBJ,''!'',";:qF';1Rle Edt: Text eel Ta Dtbug OtPtap 1lIbIaw"

Q($lIIi •••• ;.;,: ••• ·f.· ~iJ~<awJfuIil ''''''l', ,1 ., l)~tl-:'J'L, ,)f: ':)",.~,:i~I,"":~ r {:ff2-

3 - aJphap-Z:alphu-4S:<I. fpl-400; tpZ-UOO: hit-ZOo; hZ-UJOO;5- '-5000:Iii- vp·[Z·pl·tpl/r. Z.pl.tp2lr] ;liIlt-[2·pl·tlll/r, :<: ·pl·fllZ/f);., ",'.' f:-, n'J '.)',~ ':\',V."f.: 1:;:l;'q<:'<H.'.'''l ',l~"~ (,l':.1i,f ;;t ':.h,', 1..1.]t.'ife­,10­

11­lZ­l3­

14­

t!­16 - xlab.l (' !".1\·l\1~1~"rl'l trt:','.ll'!Iv,' ~" ) ;17- vli!Wel(",I''1il'. in·<t:');

10 - ax 1, ( [0 1 - 400 50] ~;19­

20­

21­

22­

23­

24­

25

Fig. 34 Chebyshev (First Order) RPF

Chebyshev-I BEF

"i'lLl....EBDJB~p

magn~udlresponSl

t£k' If;i ili l'lmiij.Et:-··...:·····t······,······i····:··l····:··:·····~o 0,1 02 03 04 05 0,6 0.7 DB 0.9 1

normalized frequency

I:lmt:jl,+'.cnm.iJ'~i.:~'Tnu,uu,!l~rFFj.40 0.1 02 OJ 04 0.5 0,6 0.7 O,B 0.9 1

normalized fl'lquMlc~

xlaDel{' !JI.'nwll~' ~',n'j ;:~'r;qW\r:'.'\" I :ylll1:lel("J"ir. ir,'J;;');axi! ((0 1 -350 50]);

(b,aJ"chebyl(n,1II1pblllp,wn,',",")"I;' .:-;",r'll .• ,·.'~I.i.'H l"llt EdI .VII¥i'!lIMrtTo* o..ktop •.·WWldowHIb

;:~~; ~~~:~~ (b, a, w): .q::~::~fj:,i::.:~:i(ti(~.:~i:~rO~:iN t1_20·1oql0(M~(hj):IIInq-lIInqle(h);.ulJplot (2,1,1); plot (om/pi,m); ql:"ld ~·n;

.UbplQt(Z,1,2); pl0t(Om/Pl,8lIq): qria 'J:'::

l! Illbe 11 ' ,'''',~<r<'\: ;. .",,-, "·'·,'q'.I<.'[,""I' 1 ;

ylaDel("~J;~n,lI\' '" :·&.-I~n"'l:

axu(IO l-q 1J):tltla('t'·".d'_ '.c.';.o"'l'ISf,'):

ar~r·,·!r'linn.'!'N"'ln9!+"NIl !dI Tlxt , •• Toc* o.bug DllltOJl WIndow .Hilp

[).Ciilliil ....'- ••. " ..··.~..·~,.f,llItJ~'9;ID1J0~. 1 • ''',' v;n '."f. ':~,"~' \'.'$l\,-,',' ,·.1 H.:'

2- clear 11;1;

3· alpbllop-2; alpha.-'IS;'1- tpl-200; tp2-18001 tlI1"'I00: t.2"1200:S - r~sooo;6 - wp"(2'pt·tp1/r, 2'pl'tp:a,Ir):"II-(2'pt'hl/F, 2'pl·ta2/1)17 f,,~,'u.1• ',': ,".:;','".(:1. tr."'.",,~\c;: ,..,m\ '.\T,··,"~',c',;. '.-i;',' i"J,,"'-.I~I.

8 - (n,"nl-cho!blord(wp/pi,w./pl,alphap,l!l.lp~):9 ~,~)fi",,,:\, f""," ''-'.'' ..". ".t' ,. "'" f:i, c,"}"

! 10 ~'11­'12­13­

14­

:15­11­17­!O­,,­20­

21­'2Z·'23­2i­

25

Write a program and plot magnitude and phase ofChebyshev-I band elimination filter.; TIT'.

Fig. 35 Chebyshev (First Order) REF

Page 35: Dsp Matlab & Two Marks

Introduction to MATLAB • MAT·29

Chebyshev-II LPF

Write a program and plot magnitude and phase ofChebyshev-II lowpass filter.

R'i"IV""')"!"""'·"1•••• [(It Tm: 0tI ToO!I ~'Delttop ~,~

D.cilil.X ••"'.· ••.,••••·•••'("f:LtlttiL·Il ••·&l(lllii.,..,i,

I.

"\'.1:'(1 tn~ ·~,~t;~.'::::t'l'[:~q'Jelic:: ,n,·:' ()r:;le~' ':t. ~h~ tll~l':t

En, vn)"cbeb2ord(wp, "=', alphap, alphall) l

clear ell ~J

alphap-2;alpntul-'1S;tp·800; 1'JI-1800;r-5000;wp-2·tp/r;lflll'"Z·ttJ/r;

} IIt:Ulll 1 f... "r.;Xj

1~[-r1fmm1o 01 0,2 03 n~ 05 06 0.7 O~ 09 I

noflna~zed freqlJIIlncyphUlruponu

Illl!EB;~0,1 0,2 03 04 05 06 0.7 0,8 0,9

normalizlldfrequlll'\cy

"lit Ed!: """"lnMrtToaII Dtlttop.'Mldow I1IIp

6(ililjT~J<!iE\6~\iI!oi] ,,[][b, aJ "chebv2 (n, alphap, vn~ : 1.11 '.'.~I: C~·'~.~tl~:H.nt",·O:O.OI:p1;

[h,OJIlj-:l:reql (1:1,la, v, '~••,":ie' ) :m'"20-1oQI0(eWll(h)) Ianq-.nqle(ll.) :.ubplot (2, 1, 1~: plot Iolll/pt ,Ill' J gr1c:1 "'[01x lab. 1 ( , 1\\.-1'11·'-': .I ~~•. ,,-; 'T.', ..;\~~~,,·.';' ) ;,la!:lel('q<'\li' H, elL' I:.Killll[O 1 -'10 lOll;

title (. """,;(r,)t '''1r. t~.t.~,,';r,.1lf'):llubplot(2,1,21; plotloll/pi,an;): ;[io1 ,j],:xle.b@l(' n.-.nk,].j '."...., j"''-:''\''''.\;~ ;" ) ;

,label ( ..?i'.!l!'f"! ill t~d'.ar.'):ax13([0 1 -3 J]);tltle(' >'~'-''''''~,:~~~,";I!(:'):

1,­,­,­,­.­1,­,lO­

ll­IZ­13­

14­

15­14­

11­10­,,­lO­

ll-"ll-l4­

l5

............................. " .-Fig. 36 Chebyshev (Second Order) LPF

Chebyshev-II HPF

Write a program and plot magnitude and phase ofChebyshev-II highpass filter.El'lunm1'!I,:uD""n,I"."nqnrr I"r 7' 71'. Edit T"lt cell ToolI DiburiI Owkop Wlrldo¥; '"""

Cl riI ••.... 1 "" •• '" '< i • : '" f. tJ Ji) . {(j 1!lI mr JGl1tll •••• i

,.1o'fI)(

EBrns/;[j

ILiff;- : I I j

0······,· __ ··,·······:· , ,-.~---t. __.._--_.---7-. __ .~ .. -

~ .10 . __ L L ' .L L .J L ..L .. _.. l. .. _.

I. =+,' ·1-"­·30 --- _.. ; .. _... ~... _. r·····f ""--1'" "'1" ... ·t-··_·!·_· ---r-" -.

.400 0,1 0.2 0,3 0.4 O,~ 0.6 0.7 08 0.9 1normillizedfrequency

phaserllsponse

~ l'E'urc 1 '••• I r:J 1)(

•••• fdt: YlIW hert T~ .·DelkCIP ~ .• Help

D~I;I.J1~€\~~i'4i!' OG "0(h, Olll]-treqz (b, a, II, ' ",I"",,' I ;

{b,a}-chab,2(n,alph.p,vn,'hl.;Ji\'I: ~ fllter ~·:;le.t:::i_O:O.Ol:pi;

alph.p·l: a1phaa-30;tp-1I'lOO: tl!l-aOO:f-SOOO;wp"Z-fp/r;lIl!1-Z"ttl/r;

.uPplot(:.I:,l,2); plot(olll/pi,anQ'l: Q'[id ,:;:'';

vlabal('r]',"'~" ,:,,(ju\l~'l;axunO i -3 JJ))

m-20·1o;10(~. (h) I:ana-angle lh);:lul:Iplot(:.I:,l,l); plot(om!pi,m); 9[id '-'Ill

x labe 1 (. \',',1"'11-¥\, ;. '~~'j.~r "'~'U'!l,~:." ) :vla!:lel('q:.un '" (H;'):ax1a([O 1 -""0 10]):

1:.I:~ clea[·" i "~I,-,­,-•1­,,­10­

11­ll­13­

14­

<S­

a­11­1. -" ­'0 ­21-

22-l3-"

(1<~il~-·'i:·..N;',:~ltmi;-I;I:-!:-1;1j 0 ·····T·_·:~~tj---·_·r·_·_·! i······ ( ! !

Q. ·2 ······;-· __·_j·····-t-·····r·-··-·1···_··t· __··_~·__·-··r···---}-,··

o 01 0.2 03 04 0.5 06 07 0,8 0,9

normlliudfrequency

Fig. 37 Chebyshev (Second Order) HPF

Page 36: Dsp Matlab & Two Marks

MAT·30 • Digital Signal Processing

Chebyshev-II BPF

Write a program and plot magnitude and phase ofChebyshev-II bandpass filter.~*mmnll=m1l

"" E.a Tnt eel Tools ~ 0Mtup Wlrollo"I ~

Dr;ii:(i •••111 "" •• ,.i.ijtJL4\~rll'iB$'';'.- .. " --.---_. __ ., ,

1Il1ll8/11:g,

c:le~f '~),;,I

alph •.p·2;llphu"4S;tpl*100; tpZ"1l00; t,t"200; t"l"JSOO;'''5000:

.,,,·[l'pi't,,t/F, "pl'tp2/r).u"(Z·pPbl/r, "pill,Z!'];

0,1 0,2 Q3 0,4 0,5 06 07 08 09

normalilldfrequency

1O~~~::'~~-~-~-1~ ,:')n. :: ': r\(~\(~1I'" , ], I[

• JJ . • t·.., , . , -'----_J

o 01 02 03 04 0,5 06 07 08 09 t

norm~lilldfrelluency

phlll.responn

I'll ElR' 'I'lIw "-t T" DMlrtop 'tl/hXIIIf ...,

[J~IiI•.. ~.I!l.EU',~ ~ l:l~ 0

[n,lO'n}"eheblofrjlllp/pl,wlI/pi,1Il1phap,1II1pha'l;

[b,aJ "cheb?2 (n,alph.p,lII'nl;lI"O:O,Ol:pi;[Il,oltl)"treql(b,e.,v);1'lI"20'loQ'lO(VllIih)):

IIlnQ"anqle(n);,ubplot(Z,l,l): plot!ornlpl,llI): ;t"il1xlabei I );

'J1Mel I "'.:\;.r, ',t~ ,~ll' I:I!lxiSI{O 1 -40 10J);tlUti I:subplot(Z,1.2); plot{om(p1,anQ'); 'ilrldd~ell

,LIt1.! j "I';' ~:~l' .Ii, 1'(1,1\ ~I".' ) ;

8olrl'I{O 1·33J);tltlej':, )1

12­J.,­5­,.,e·,lO­

ll­12­,,-t<­15'16­

to­te·19­20­

u­22­23-24-"

Fig. 38 Chebyshev (Second Order) BPF

BPF Chebyshev-II BEF

Write a program and plot magnitude and phase ofChebyshev-lI band elimination filter.

~·tltfi .nllf mrllll1I.·1 I"File EdIt ttllt eel TOQIl; 0ItIu9 I)nI¢Qp Wfllklw ...,

D ,. liI •••• .., it ,. f. fJ t1 % 'h t' I[Ht FEIII 8 /II 'g.

..,

lUJPffmbFiCTjJ3li'" =--+ fj'··J..·.·....·,·..·,.""'. :....·l·lJ -t· ; t··:L; ;..-.-.: ~-_~ ;. I.40 'i j'!' '-L~---l

o 01 02 OJ 0,4 0.5 0.6 07 0,6 0,9 1normalindfteqlJency

ph.$8rISpOn8t

••• ·fCI'Mwlostitf_tliiItGp~~

[J .." ..IiI""~.~<>'~.~'l'(JJll ,,[]

cleet1 - 'IlJphap"Z;fllph •• ·'1S;'l- tpl-ZOO; tpZ"1800; tl!ll"<I00; t.Z-1ZI'IOJ

'''501'10;

6- up"{Z·pt·tpl/r, Z·pl*tpz/r);·I."{Z'pl'hl/r, Z'pl"faUf);,.­,

10 - (b, fll ~<.:hetlyZ (n, .Jpbllp, ",n,

11·· ."O:O,OI:Pl;lZ- [b,oIDJ ••treql(b,tI,IIII;11 - ",'ZO"loglOlab"lh));1'1- flnl;j"llllgle(h);15 - ilubplot(2, 1, i); plot. tolll/pl,m~; qr1d16 - xla,be 1 ( ,,':·rv> J!. ';e,' .;1 tt"""';:'-l~,,'.'~I');17- yllUJel.(·'Jmr, '1, ,i)I'):1f! - a.l!I([O 1 -40 lOll;1SI - t 1 tIe I . ~""q l'.' ,;",1" r', .11'<" ,;,<,,' ) ;

ZO - .ubplat(2,l,Z); plotlolll!pl,anq); ql:ld;) 1 - Xlabll (' 1,,;,r~·"'.J;.:-. ;·.1 .fr,',",;.l,· I.";'," );

22- ,Iabel( I'~"'''''' ,\, ,__,~jj"'~'I:23 - •• U([O 1-) 3j);Z'I- tHlel·"j·","·"

~,0

Fig. 39 Chebyshev (Second Order) BEF

Page 37: Dsp Matlab & Two Marks

L

Introduction to MATLAB • MAT·31

Analog-to-Digital Filter Transformation

Write a program for converting analog filter coefficients into digital equivalent filter coefficients using impulse­invariant transformation method and Bilinear Transformation method.

EEI·'II"IIl*II'Ill"Z1"II"I"'IIl·EI·Il'III'III'I'II·.·IIIII1'II!§'I'IIlMIiPIlI· ••••••••••••••••••••••,..!lIt T.llt CIlI loch ~ oIslUp w.-.~ "':IlK

D Ill' 'I: J •••• ~ " • ," f•• lltl <il1!Il ~ JiiiHII!l , ••• ,' IIIill Ell'lg1 '••.•,,"'.'\1 :." ,H'FI'.-,-,I -rUt""\" '.I.-••.m't';n"' .••..:un,3 ~1'.f.'n".l'.\';1\~~,t h,",l

.-5 - b-(l2];d- .-112JII'7- b-l:I!I- (bl,.11"11ll1'1nva •.jb, ••,:t~l,

OUtput

b ••1.0000

1.0000

O\l~P\lt" .

Fig. 40 Analog to Digital Converter

FIR Filter Using Rectangular Window

"nl- Inpllt I ..",'" "r ~ \' r r.,~:;•..,r.,"'n',un2-1npllt I '~,,'n,,'" i ';",~.~~:;>i'1":I;,·\\t," "t ••IIel-"I'I1"p11"e2·vl\2*p1; n·O:l:N-l;1lc1"('in(IIcl-(n-.lpha+ep'l )-llln(IIc2-(n-alpba+epll) )+lIln(pl"(n_alpb.+ep"))) J (pl-(n-lllpba+eplI) ~;

oelleCull'e

"

dhp('

uct·cectvin(N)/.lIubplotI2,l,ll;plot(cl!etl;tltl.I' ,:~':'t-~:l;:\\l~" ';, r.,C!(,,;, I lxl.al (' r,' I; ,181:lll1(' ~'" j;IIn-hd."c.ct'; '1:,\,,',"" '-";.,if.,\';"''''·v-O:O.OI'llull-tceqv1I1n,1,lIjl.ubplOt(2,l,2);plot(./pl,20'loglO(llb,"(II)));t1tl.I't:",,.,·,!,,,,,,,,\, ~~tiJ':,u~",'I;x1llb.1(·!J,~::;"","i,,~J. i.'~'l, .•"l:U·1 I: ,label( "'<)'\Hl.'. ..:(l", ~,;l;:;t')1,

'·'''·'WfiiiiU¥''''$''''U;•••• fdt Tht CIIIIToOk llIIluiI Dllltap \MnIbII ~

Dill'. , J ••••• <'. " ••• " !..111Ji]} • ' •• !I' iO liI _C".1 '~;:;.:;:;'~t,'-:;i: ;>; k t, ,'t.:;:. :".~i:';~"'i<;;l;:;;·;..•i\ur,): ",\!"j ..:'\,2 - N·tnput.I'~"v"J: ('M '!'r.,~·.)' ,'1: '.'\1:' ',~':t"·l\r,~It\3 - tPl:lDttl''.W:l ~ ::"J:l-.,~"",,~ t:"i'."~ \,;4 - tfpe-1nput (' f J..,,,,,r :',\'~r, ) 15- tpclntt(';"l""'"l;- a1plla~ (N-ll/2; ~p."O.OOl;1- 311011t(;11t,p.8 - "'•••~ 1

51- lI'l\~lnput (' N'''·' ..,~,i\1'1',1 ':",' (..t.t t","',!"",""",!",

10 - IIC·"Il-PI; n~O: l:N-l;11 - hd~lHn (IICO"(n-lllpha+ePII) l .1 (pi- (n-alpha+~pll));12 - CO!\lIe2

1] - 1I'l\~1nput(' !l',l""'" ,"'1',i ",,\, .,,';i-.t !r,"",l';<'''',~r,14 - uCO~un"Jll; Il~O:l:N-l;l! - hd~ (llln(pl"lll~.lpll.+ep.ll-3I1n("c" (n-.lpbll+epllll) .1 (pl" (n-.lpbll+ePIl));16- I:!II""')11 - "n1·~npllt (' ~;'-."M.l, ",,\'1 ;18 - "n2.lnput (' i'hn"~;,,,~~'; t\"<"':l"~""'h,~, '<Ii'HI - IIclallnl"p1;wc2-lIn2 'pll n~O: I,N-ll20- 1lc1-(Un(ue2"(n-lllphll+ep'll-llln("cl'(n-alpbe.+epll)))./(Pl'(n-alpb!\1"epll));a-u­,,­,,­,,­u­n­,,-,,-.c­'l­u-33­H-

Write a program for FIR filter using Rectangular window and plot its magnitude response.

:a.r

Fig. 41 FIR Filter Using Rectangular Window

Page 38: Dsp Matlab & Two Marks

MAT·32 • Digital Signal Processing

FIR Filter Using Hamming Window

Write a program for FIR filter using Hamming window and plot its magnitude response.1Ji11110f (\M~II~IJf\.w,,,~\,llJh,,,,k\flf 1'<l.lt! r•. ~ x

wc.vn"pi; n-O:l:}i-l:hd;- (sln (pl" (n-slpha<teps~) -II in j wc" (n-alpbatep,) ) ) ./ (pi" (n-.lptllltepsli :

e,uul3

vcl-wnl'pl: vcZ-vn2"pl; n·O: 1:N-1;

hd"jllln (1fC2"l n-1II1phlll+ep") ) -Illn IlIel" (n-1II1pI'l1ll'feplI)) I ./ ~pl" (n-alphlll<tl!PlIl ) :cue 4

"

"

.):

"

"

IIn2"inputl't,r,n'J!1!!~"'~ urr/!:: ,~tJr,·,,·;l't .\·\"<'1(;'H·fJ'."Ir.~,'i:'~" 0);

IIcl""nl"p1;vcZ-IIIlPpl: n-O:l:N-l)hd-(81n(lfC1"(n-alpha+tlpll»)-.in(lIcZ"ln-slphuepll))+Blnlpl"(n-alpha+epll»))./(pi"(n-alpha+epa)):

otherllllle

••n-1npUt (' r;"·nNli '.~":u <":\:~. ',f'r rn··~ll:t',,,,,,,. "'1, ~vc-.n·pl: n-O:l;N-l:hd·.ln(wc~(n-.lpha"psll,/ (pi" (n-alpha+eplI) l;

;;!I!e2

w"O:O.OI:pi:h-:l:r'ql(lm, I, v);llubplot(2,1,:O:plot(lI/pi,lO"loqlOliltlll(h))):

t ttll (' (1:~4:'j~n,~y t e.,:,po"J.le·) ; 1I1a1:1el(. 1;,nll1'!.l.i,!:!\~ ~!e'~\,el,~Y'): 7111:I.1 (' liJtI~n1'_\\'i.,",t~ll; 1 ) :

t

hlUll"h_ln'iJ(I~);lIubplot12,l,l);plot(hMl);tltle('!l'IJrml1r.\l';ln';r.'V'l;xll1l.1('/l'); yli1t1elj'lIl\]'):hn-het."hM';

I"iI £dt lilt ctI ToOIl c.b.io ,btII¢Gp'viWidow •• ""',X

ci·Oi.·X·IiO.··;·;::ir"'·/:!fiii\1i1iimi·lfu,jli;';;;.:r:" .···iiiiiiEi ili:o1 ·~'r~i..i,~i;"·,ji""ftl':' i;'ii'i.'e'~···u~'i'ii\i"'ii.:V;iii~;iq"';d'i;~lO,i '"i{

~ = ~:~~:;;::~;::~'~J.t~:r~::,:~~;;/~j::;:/~~lr'·~l\~,)~J;:~~;'~~r!l)~i\'r.!:\r, ; t?f p"nd',f<,'1:ltilur: \). ~ t.'r ~€\I)<1r,Itl>;1nn~H'~, ~Uar. \n ?.• - t'VP.-lnput('!'''if· ..'t !l.", ~·;.lt.", ::n·'· ;);5 - tprlntt("<rr:r.llf ;;.'.lr1'l"·'l.tl,~,~du,.l'.l~ ~;•.•t'let.(J I:"'" \1,-):

6 - IIIolpha-{H-l)/2; eps-O.OOl;7- 1Il1ltehe7P'I!- callI:1,­lO-

U-12­1l­14­

15­

lO­

,,­>S­

10­,,­ll­22­

l3­24­

Z>­

Z6­

27­

lO­

,,­3D­

31­

n­l3­,,­)S-

;; start j h f' > I ,~ ' j f'" "'" 'J! I, ~(" lb 101

Fig. 42 FIR Filter Using Hamming Window

FIR Filter Using Hanning WindowWrite a program for FIR filter using Hanning window and plot its magnitude response.

a Id,lar l IMAIIM1J\WPII.\d jJ 11~~k\l, h,," no r.. O! ')(

,

I~.:::<!

"'i

'Il

lfnl~lnput(·l;'~"'''"~';'.i-~,j l':)>lf:l ,,'.r:;":;,,:,1';;:"'~I""['C.·"', 1',',1 );IIn2-1nput(·~);grr·'i-)\,:,)·,1 '''MJ''\' !·r,-,,,m':I;'.'i.(,~', ~l\:' 'I;

VCI~lInl"p1:uc2.lIn2"pl: n-O: l:N-t; ,hct- (1l1n(lIcl. {n-lI1pha<tepll)) -e1n(lIcZ" (n-1II1phlll+ePll)l +IIin Ipl" (n-alpha+ep8l)) ,/ (p1" (~-alPha+ep81):

vnl"input('Nr,)::lJn!';Ml',l lrillf.l: ,"P:-M::!' r.;:'~\1';.~f',G" "llU" ,):1m2-1nput (' 1;,~n,,/.\l~~ed 'XP],lI\l:C'It;-:;.:t:f t:~C!\\etK' ~~.::-, 'i"n<: M 'l;IIcl"vnl'pl;vcl-lInl"pl: n"0:11N-l:hd- (llin Ivcl" (n-alphlll+ep.)) -.In(lIct" (ll-alphlll'fepll)) .I (pi" jn·alphatepll));

othervi,seo

dl,p('~"'l,,"_;~:_l _~i~~."r '_?rll'):

IIn-lnput (. li,,::,~,~;.\ ;,~,'J ,--',':.···.~'.:-t· ,!,t'""'l'J,:,nJ':" ""l'~ ) ;IIc-.nopi; n-O:l:N-l;hd."1.1n(pl" (n-alpMtep.}) -.ih(VC" (n-alphuep.ll) ,/ (pl" (n·.lph •.•• p.)):

cueJ

1I-0:0.0l:pi.;b":tE'eql(hn,l,v);ll\lbplot(l,I,2):plot(lI/p1,20".1og10(iItI,(h))):t1 t le I ; .~', "~;,,.~._, ': [e:~;~')h""'): xIlllbe1 (' J,r;,l"rN'.!u,,,d fn'~t;l,"'t'\"): yIlllbe1 ( '"""\1"" ~'jl.l.., (ill)' I :

t

"dhan-hannlllgIN);llubplotU, 1,1);plot(hsn);tlt1.1'!':.~I.luh'J ••.i.r.~(,,~')JxlrabIl1l',','): yl!ll:lell'~lr.·I)Jhn-hl1. than' J .t, ~'.'~I· ,':r)f,t:t'l,,~~<:,r:',

FiIt Wt TIfXI: Cd T0d5·o.bIll o.IitGP YiIi'libiV ItIIp

DOi •.•...t ""II, ;, ,:... '" f.1l i1 ••• <ill mitJlIl ""',,' 1Il..m ..B..." ..JJ.1 '. l,~!I" '11, :)t, /j'i;":;~ i-i::r";_"'u~~-;-;;'~'i;;;"r.l;;-,;:- v~r.~"';:1 __1

2 - N.lnpUt(·~I\~.~'.' '.)',,, '''1'l;Fl'l 'it: ',h~ :'i"'l'lJ,~1'lq\';''''-,[,\'1 ); !, 3 - tprlnt:l:(' ',n"'l ~ :t','r!o~'p,'t.NI 1',~It.r\T."~J ~ !')\' h'(j'h;;ft:l~f..ilrl'::: \r, ~ :t'~'i'_ l;l$rJ11'~.,r t',P_'n' 'on '. 1'~I: j~•••r4 .,l~1l."I\<'1f.""):Jt~,l~,f\r. \n:!'4- type-lnput('~'""~'::'_ \',~J~H:c,",l' q"l1~ '):, 5 - :tprlntt(·~I;t~r. n"...I:I~,I)!~".1 ·;"'Ul': /;11\';"1\1':;:'r;_~~;\,');

6 - alpha-(N-ll/l: ep!l-O,OOI:7- IIIlfltchtype8- CAlle 151- lfll-lnpUt (, 1'''''1.1."''.;·,:~f".'r,-,,~ ",t,\' L~'~,,~,

10 - IIC"Vn"pl; ll"O:l:N-l:'11 - hd-rnll(vc. (n-slpha+ep.) _/ (pi" (n-alpha<l1!pll) 1"12-

12­

:14­:UI ­:16­'n­'18­,,­20­

ll-,,­n­24­

,,­H­2O­

28­

:251­

:30 ­J31­,,­l3­

;34­

;H-

Fig. 43 FIR Filter Using Hanning Window

Page 39: Dsp Matlab & Two Marks

Introduction to MATLAB • MAT·33

FIR Filter using Blackman Window

Write a program for FIR filter using Blackman window and plot its magnitude response.lilli,',' (IMAIIAIJI\"""k\<II,I",ullll" hlalloJ'd"m roO d' 'x

I

J

IBID8/HI";;;:;

'j;

wnl"tnplI.t( <,,f.,,,,,,,,,! ~ 1'1'····1'-'''10'';'),);wnZ"tnplI.t (' ;';,,~,v,1, .:,',.-' ;;;;".',~ ',',",'. ,"J.;; 1r";J,.,,";t;,n-, 'Hl< ');IIcl-lI'lll'pl;Vc~"vn2 'pi; n"O: 1:1'1-1;hd.• (.tn(lIcl· In-.lpha+ep.) 1-.tn(IICZ·ln-lI1ph.+ep,))+Un(pi· In- alpha+ep.))I,/lpt'ln-.lphl.+ep')):

wnl-lnplI.t('!ht"irl<l~,;~'I'J )(,,,r,;; '.'1" ',tf '!::,t>'t"",r."!', ~1\~' '):vnZ-lnpll.t«l'I·~nNll;~~d. '-i"p~~ ;<.;~··•.:tt. tr~·:ruer,c:'e", i'n?" 'J;vCI_IInltpl;IICZ_wn2tpl; n-0:1:14-l;hdw(slnIIlCZt(n-.lphal+ePII))-s1n(lICl·ln-lI1phuep!)))./(pl·(n-.Iphal+epsl);

IIn-input (' ~;,",;:m':\),.a~') '.'ll'.··I,tt!I~IF"~,'~~',"n ~ '):IIc"lI'll.p1; n"'O:l:N-l;bd"(.1n Ipt.ln-alph.+ep.)) -un(lI(l· (n-alphal+ep.l)) ./ (pP (n-alpha+ep.)):

black".blackman(Nl;s..wplot(Z,I,l);plot(bll1C"k)Jtitle (':~':"":'X:l$l, ",::::k,i") ;Xlllbtl (. I,'): vlabel(' ~rr,; );IIn-lId. °black' l 'f: ltH ,~,:,~tft;;~1"

rO:O.Ol:pl;lI-tuql(hn,l,w):.ubplot(Z,I,2i;plot(V/pl,20·1oQl11(aIJ.(h)));t 1t Ie ( . ~r·~'1"~,,(.'I r...,,,,~',!l~'~' ) : lliabe I ( , n"~••,, , ;.2,~.i £L'''~'l~~, ,(..';' I; ,lllbe 1( , ,,,.-.•..•,1':.•" '.t.i•.~ \dl!J .- I ;

.~;.

''.'''~'q\1 c·! Frr !l,~',"~-;I.~"~.::Ji~·.\,,;ir..":l\!, >;,i"d,'~

Nwinput('':':\~''·'I, t,\<' ('.~'" ~,:",·_,kn,1.'·~!r.d,,~ );

tptilltt('\",~r, l r.~nl';~p"'·i,; ~IL'H' '.:; t ,I;'~~u .•;"b;F<n· j;1;~~' \1:: • !c',l' c':a"~l1",~~till<~" \r,t l'pc· inpllt I ' ':'"io"lC:'. t. r.,~ i; ~ '\'.'~!. '. ;'l\~ ) ;tpclntt (, r.r.~er rJ0(Mli~;1·~d\·t..1\)~il~:~·i':·!:": 'I:,',. n'):alph.-(H-l)/Z; tPI-O.OOl:UJitch type

r;UI't

1111- 1 nput ( ..~,(" 'I~"\ ~ '~~'<l

we-IIn·pi; 11-0;l:H~l;hd·,ln(YC·(II-.1phllo~P5J) .1 (pl·jn-1l1pl1e.+ep,)):

c•.,ez

1'1IIo ~dI rilei' eel Took·DItuQ 0ItItnp 'M'llbo" ~

I:lI#III j ~Il·"'·, ••• " !HH\l~lI1lQ$ •••

Fig. 44 FIR Filter Using Blackman Window

Hilbert Transformer Using Window Technique

Write a program for Hilbert transformer using window technique and plot its magnitude response.f't"·;'jii',!"*""Wi"'@'i IIFlIIfll:Tel:l:ceiTooIIDebuilDe*l;o'MUM" ',1'X

ll ..0;;...IlT,.-.ItI.,'~' ••4II ...•••. {.Il.4).·.·.·.·.~.·.(;;..il'·.·.11I.·lIII.~ ••.•T.,' ·.··..·.·..IIJIllB~i.Ei

N-lnput(·"r.,~r "I',,, '~'·,,)r,~. '.":,,~:1~'~l''''i "r r,,~~ """:1,-." "~,r !'\':l"~" 'j;tprtntt('·.;.'.',n.l H:·.".'-'I:(l'';,lt '11 :. r~'r :,'.I1''''j,,,·.J',,, 3 {f.,r :·J~.llr.l,," ',', 'I t.(,L· t""C'"J<-I't..'," l;

w~II-~lnq(NI:oSIIIe3

Wln-banntnq(N):caSl!4

'Iln·blaclallan(N):other"lse

dlSp( "'1(:':')1."n-O:l:N-l;

hd-(l-cOII(p10(n-.lpha+eplI)))./lp1"(n·.lphal+epll));hd(dpha+l)-O:hn"hd.·vln';

1I-0:0.01:pi;h"':£nq:a:(hn,1,w):plot (lI/pl,iO"lcQl11labslhll):tit 1. (, (":~'l"~"'::~.':"~ll','l'l~"');lllUlel('~",i:;'''U.\,·.-:,1 .h<'!'''',~''",'\·'I:,label (. ''''''.'', II

. "ire 'I;t,pl!"lnpllt.(·N';~"alpha·(N·l)/Z; epII*O.001;,",u,l!,,'htVpl!

<';!l!!l'1V~n-rect IN):

1,­,-.-

, s-; 5­

7­,­,­

>a­11­U­

'13­14­,,­

'u­n­

,le­lO­,.­

'u­n­

:Z3­i4­

'zs­,u­'z?-

':::::::::':"::"~'::;~'::"::'c;j::;;'::::""

';start. j"'lIJl.J •.•.• ," ~~l~' Dl' Ilf ?( 1'1 I {

Fig. 45 Hilbert Transform Using Window Technique

Page 40: Dsp Matlab & Two Marks

MAT·34 • Digital Signal Processing

Differentlator Using Window Technique

Write a program for differentiator using window technique and plot its magnitude response.

"" &t: Tftt Ctlr."iIebug bliikl:ap 'iVfldliW.

O~.t ..IIl,,···.:.'" f,l1e~~ilill]$""":;;;;1 ... f, (;;~;j;',)1' ",'{ '.I!.!: r,,:;,";;;;; . .i 1>.\:;:;.;.:";";:;" ~'\J ..~ i,:'.k~'I' t.·t~';iln .i·r~\;,:;;;····· ... .... .

2- ct.-roil:3 - N~lnput (' ''',(' .•.., '-"',J',;; I;

.•. - fprtntt("\r,\r r."t':tll)';r·r\:u ·'.t\ i.: t',r rj'll'~~,:lq 'u; 'i t·,~·r'l.I1T!l:\<1',1: ~ t.,';~'5 - t,pe-lnput('F'!N,r. 'h", lJ1:\ct'11' '"7pr, );

, 6 - .1ph.·(1~-1)n:7 - "¥ltch t,pee- cue 1

9· "tn-rect(Nl:10- c:."e211- ¥In-h_lnq(NI;12- cue J

13 - uln-he.nntnq(NI::14- cue":1! • vtn-blackmaIlIN);118-in- ell.p(" '1\'/~.',1·.1 t.\\~,~[:tVt;,~,):!11!1 - end

1lSi - n-O:l:N-l:

:20 - hd-CCl.(pt·ln-alpha)),/In-.lph.);,11 - hdtalpba+l)-O;

z:z - bn-bd.,tllin'; H~l';.~, ;o~~'nr_i"'I,1,;

jZ3 - v-O:O.Ol:pi;b-fnql(bn,l,.);Z4 - plct(v/pi,ZOI10910{ab'(b)));

'l5 - titl.(' !r,I!'\t'l~n,~1' fr:.'l"·,'/"'t.');2' - xlab.l('I,,-,r~,.'.)ul!',l .ht.,'{u,'w,",>');

'21 ~ ,1ab.l(',\"sW"~'j(il!' "ill:'):

.; IIX

£BOJE3il'Q

n'):

~ .... ·, .. ··· .. ···· .. ·.. i·i,ji· ..i ....·Clii .. ·1....

'~ stlJl1 jt ; ,. " ,oJ I,' a I of( ,.. " r'

Fig. 46 Differentiator Using Window Technique

FIR Filter Design Using Kaiser Window

IIlID 8 6'![l

Write a program for FIR filter using Kaiser window and plot its magnitude response.f-'§ijt.iee'ifi'iil'Ei""eEFI

I'lIt !ell 1m ~ , ••••• DIbuQ 0I111tGp ~ ••

o~. ,u" ,; .!"i.lithll_WlGlilll -'c'8M

..:"x

: 1 .'("'1'j'i):' _.I!: "",b.~r, "~/"~,''11:- cl.a,,,lL;3 - N-lnput (, r~IV'-'\

. ,,- b.llt.-lnput(':o"l,,-:t ti".~ !",~~r.,;.·:~,.l,-,,, );.5 - "n-1nput (' "n"'!r ',b", ··;;:r.·dt tn~rl,;~r";:1 ');6- uc-un'pl;"I- b-.l:1rl(H,uc!pi,ltal.U'[Ntl.b.etal);e - n-O:l:N-l:

. SI- ,,·O:O,01:pl.;:10 - h-fnql(b,l,v);:11 - plot(v!p1,ZO'loql0(ab.(hl)):in· titla(; l"·t".:ut''''''1 r:"'I!,')\\!!~'):

:13 - xlabel('",;rn"jJ_~~.,'d J:lf:r(\w.w;,'):1'1- ,lab.l('~~:V,l~'.ld~ :dllt'):

i.,. "' ':~~::'~~-':':':'c;:::~"'"

J~start jt~·..-t"f.!"'~ i;JI ,. r" k~ 'I

Fig. 47 FIR Filter Using Kaiser Window Technique

Page 41: Dsp Matlab & Two Marks

L

Introduction to MATLAB • MAT·35

Up-sampler

Write a program for upsampling by an integer factor and plot its magnitude response.tll.i!.'I!,"NB'AMMI.I"lI Nt Tm Ctlfooll DItiug.:0it6Up ..•••••

II ($. 'Ill ••..•,:;:jiAf.iille>l.iI'i(]ljl _[is;

"

1'£lJIcl •• 1- x

~in.ut.",",""

0.5

tE '

.~:~~o 5 10 15 ~ ~

n

(~o 5 10 15 ~ ~

"

,.>~.•• 1riMIt ,_ ,~:, •..,.. .-

llQilrile i!J;e.~~$ i.'!iIIG ~ tl

Dl't-lnput("'I,';",r ':h.(, H;J",'\Tr:r f.~I.'t."", .c,.'! ';l'~~t'l~~i~l'l\l"x·'ln(Z·pl."O.12"n)J

'-llI!tOs(1,lllt'll!nqr-h(llJ l:7((1: 1D1: leng'thl,lJl-x;subplot(2,l, 11:.telll(n,~) :tltle(" 111'(".'- ~(.,Iunl¢~";llIKiel(' Il'); yllllJel ('>.ll.lP;'lt'j'd~·):

subplot(2, 1,2);,ull(n, 9'(1: lenqth(x));

" 1,[!,!>lW,'), ~I;rj '., 'j (,,, ~"~·.1"1r'l't'fJ.' '.';rct •• tAll

N-lnput ("'n!.!," r ',:.,. l;·r,~':'~ ~)'!' Uk' ~-''''F''r~'n-O:H;

·1,­)- clc,,­6­1­,­,­lO­

u­in­'13­11­

,1.5­:16­;n­11-

-lj start j I J .,j, ~ ~ j ~< •••

Fig. 48 Up-sampling by an Integer Factor

Down-sampler

Write a program for downsampling by an integer factor and plot its magnitude response

~91i',m,ln.li"~,~l!lf,alil'Clnsu!.l=~S~!t!!'!Il1'1lI=~,D~&='U=·,I~~mll~·~:'!~[ ••••••••••••••••••••••••• ,I"lIr rdt: 1m CtI,ToalIo.buOtMIWCfl'~ HI$ •• ~ •• )(

D ~11'••iiii:;;:...i.iiie:{i" ~ibi!!.-""..IiiCilEiilij5

r'~lHC' .• I' ••.• XNt tdt ••••• htrt, , •• 0t*0P ••~ 'HI/P

D"liI.'i~\e.E\~ $ ~itiD" t'J

i~~o 5 10 15 ~ ~

,I,N-lnJlut("-' ·,r UH, O<f,"I".""'·' ,

n"O,H-l;

lIIt.tnp\lt('~l:.t;~t". tho!! liH!!!Q'<:!rr~c';·,r :tc~ \\;:!I-:\tIll'!lllq" I:•• OlN-lIlt-IIx"lIin(Z'p1'O,04Z'llIfl'-X«1 : lilt: Iltuqth(xllll.\II:)plot(Z,l,ll:Itt ••• (n,ll(11N));title (' j nt" ••· N"''l''<'''''~');xlablll(',,'): ,1Ul.l(·ffl'tlp~.\;;.'.l'~'1";.ubplot(2,1,2);IIt•• (n,') Itltll(";::;VIH'fl\llPl"",l ,'n:')"Jl' "'!~\it;r.,:,r.'J;xltltlltl (' 1)'); flab.I(' 00'.'p!lt\l,1e'j:

"

~

0.5

'~:~~lo 5 10 15 E ~

Fig. 49

-Down-sampling by an Integer Factor

Page 42: Dsp Matlab & Two Marks

MAT·36 • Digital Signal Processing

Decimator

Write a program for decimator and plot its magnitude response.

~.:."~"~, ..TIllIII."'~,:RiIPi:j·i#!iI ..•. :~Ji.~"~,~~'~'g~IIP '.

'I,

~ d~HII;J:IllI"J..'lir:.q):,1 a~. intt!\1Ut tlioJ';i.ll'c:learl~ ;,1'N-input (' ~:n.r/?r toh,.. ),~l\(lr,b I"I!: t.b'! :~{,qu/?r;\,,!~ ) J

A-O:M-l;

l-lnplltl'':':lll'.tt d.", j.f",t'JI':t: f(ll'\'.t'[ !'ur ,1GloIldWnvlill"'''

1l-1I1n(Z 'p1'0.042"n) +81n 12'p1'0. on 'n) ;

rdeci"'u Ill,JIll;I\lbpJ.otIZ, 1,11:lIt_ln,xll:N));titl.1 ':rlP\l'; Ij~qUfrl'.(;rt; J:xlabe!(' \'l') I ,label ('Nnf'; ,(('wl..,'):.\!bplot-(2,1,Z):.0; (N/I)-itato(., ,I 1: (N/III):tielel' 1i<t'~UI""t'!d 1,;'1.\ :IU'. P-r.qUClI\t'.-r' I:xlabel('Il'J: ,ll1bel(''itl'p.~1~.ur1~'I:

i 1z·,.,­s·,­,..­..

'1.0 ­

:11 ~iU­in ­...'HI­u­11-

.... , ~~~:::{:; Qij" .. " .

~ sfart J 1 ~ 1 I;;,., '(" I

Fig. 50 Decimator

Page 43: Dsp Matlab & Two Marks

Introduction to MATLAB • MAT·37

Interpolator

Write a program for interpolator and plot its magnitude response.fJMI.fI!'Uflll"iiM"'ij'§pS!tF'- Eci Text Cell rcW.D*lljI.Dttkop"Wli'lduw"

[l ~.i"'.;;" .•.",f;:i1i~~~Sri1lili:"""'1 III[DB /HJ .." '.r.r.:'r;'.·.1·~(1·11\: uj:·!l~-r;r·\ inti 01' "~r: ,r:::·~qf:r tl'.~r_.,rchar .ji':',"

l~.~ 5 10 15 ~ ~

"

t~~O 5 10 15 ~ ~ ~ ~ ~ ~ ~

11~1II~ 1 r •. 11'"' X

i'lit:" Eii:" 'In*:Ta ~. 'wwt;w: ••

[l~IiI.I,ii(e:O~ itili'l "D

L· i np ut ( .-,..~II, r:-r '. h •.: " r,', '-~\l'-:r ','''','1" \II: 1. i;~x-.ln(2"pl'O.01:Pnl+s1n(Z·plTO,03Pn);,-lnterp (~,Ll:.lIbplot(l,l,l);IlIt91(n,ll(l:N)I;

xJKltJ('\\' I; ,JaDe! (, '!I1"f,li'.:;;;It:');8u))plot(Z,1,2);lll-O: (N°LI-I:5tt •• (m,J(1: (N-LIII:t 1t 11 (' ,l',': '!'l';;"1j.~t~~;t ')\It 'Put ,~c:,\e!·,,~••' I;lllabel (' I': ); ,laDel (: ""~f,' i ':.",,:11" l:

1,­,­,­5­.­7-

; 8­,­

10­;11­IlZ­;13­:11-,1$-:\6­i1'?-

Fig. 51

all·· mm •• iimOiiim ...•

Interpolator

Sampling Rate Converter

Write a program for sampling rate alteration and plot its magnitude response.

~~'~IJ~~,\~UII~I!m;~"lm~Amn=!W~"~lm{ga'~m'='lIlm="m'~,J,=",~a~!!m"~¥!I';I)••••••• 111111111111.1111 ••••• 111'.1.f" Edt Ta. e.1 T/lllk DItiuIlOesltop""'" ~

n <Ii'11II', 'Ii ft <> .> .• '" f. (J:iJ '" ~ 111110lltl(... ... m m 8 "[It

."."

,..fdt,YliiitIi'iiilirtT.~~'·~

[l~Iii.r~ ~e:~:i)\l!ti~!••[J

I.-input (!I-input I' ,~"',,"" \"r.,;r'l":': t)!;','n .L'I ,1{,~r,."'''1I1~1'J..\;''l "

1l-.1n(2"pl·0.042·n)+!I1n(2"pl*O.03'Pn);,-r'''llIlpll(X,L,1I1;lJutlplot(2:,l,l) IIte.(n,x(l:N)};tit Ie (. ,r,:; u" ',',~··;u.', "' __,. I J

Killbel( J)'); ,label (' .-.n';'~.u1:lplot(2.1,2);IfI"'O:(NtL/ll-l;IUIIl(JII,V(l: IN'l.1l1) I) J

tit II ( . ,..t:: .' ~Il '~t::l.lU" nel: );

lliabell' I,' I: VI.btl('·"'"!,) ..:':."L·..··);

\ .,~" v 1",

cllar,,;),"N-Input'

1Z­

,­,­,-.-

. ,-8 ­,­

'lO­u­u­·n·'!'t­15­

"16­,,­18-

Fig. 52..• ~mm ... m,;;;

Sampling Rate Converter

CuI. 1,;'i.

Page 44: Dsp Matlab & Two Marks

Two Marks Questions and Answers

Chapter 2 Introduction to Signals & Systems

1. Define signals & systems.

A signal is defined as a function of one or more variables, which conveys information.A system is an entity that manipulates one or more input signals to perform a function, which results in anew output signal.

2. What are the classifications of signal based on their properties?

Continuous-time (CT) signal and Discrete-time (DT) signalPeriodic and Aperiodic signalsEven and Odd signalsDeterministic and Random signalsEnergy and Power signals

3. What are the classifications of system based on their properties?

Continuous-time and Discrete-time systemsStable and Unstable systemsMemory and Memory-less systemsInvertible and Non-invertible systemsTime-invariant and Time-variant systemsLinear and Non-linear systems

Causal and Non-causal systems

4. Differentiate between discrete-time signal and digital signal.

Discrete-time Signal Digital Signal

A DT signal is obtained by sampling a CT

A digital signal is obtained by sampling,signal at a uniform or non-uniform rate.

quantizing and encoding a CT signal.

A signal x(n) is said to be DT signal if it

A signal is said to be a digital signal if it is

defines or represents an input at discrete

represented in terms of binary bits ('0' or '1 ').

instants of time. The DT signal is discrete in time only.

The digital signal is discrete in time andquantized in amplitude.For a DT signal, the amplitude varies at

For a digital signal, the amplitude isevery discrete values of' n'.

represented as a high voltage if the bit is '1 'and low voltage if the bit is '0'.

Page 45: Dsp Matlab & Two Marks

TQA·2 • Digital Signal Processing

5. Differentiate energy and power signal.

Energy Signal

The energy of CT signal x(t) over a period

T T.. b-- ~ t ~ +- IS given y2 2

Lt +Yz

E = " f ix(t)12 dtJ ~ ~-Yz

The energy of DT signal x( n) over a

period -N ~ n ~ +N is given byLt +N

E = L Ix(n)12N----1oon=_N

A signal is referred to as energy signal ifand only if the total energy of the signalsatisfies the condition 0 ~ E70 ~ 00.

Generally deterministic and aperiodicsignals are considered to be energy signals.

6. Differentiate even and odd signals.

Power Signal

The power of CT signal x(t) over a period

T T.. b--~t~+- IS given y2 2

Lt I +Yz

P = - f Ix(t)12 dtl' ~ ~ T -Yz

The power of DT signal x( n) over a period

-N ~ n ~ +N is given by

Lt 1 +N

E = -- L jx(n)12N ~ ~ 2N +In=-N

A signal is referred to as energy signal if and onlyif the total energy of the signal satisfies thecondition 0 ~ Pcc; ~ 00.

Generally random and periodic signals areconsidered to be power signals.

Odd Signal Even Signal

A signal is said to be odd ifx(t)=-x(-t) for

A signal is said to be odd if x(t) = x( -t)for

CT signal x(n) = -x( -n)

for DT signalCT signal x(n) = x( -n) for DT signal

The odd component of any signal is

The even component of any signal is

x(t) - x( -t)

x(t) + x( -t) .

x" (t) = 2 for CT signalXe(t) = 2 for CT signal

x(n)-x(-n)

x(n) + x( -n) .

x,,(n) = 2 for DT signalxe(n) = for DT signal

2Odd signals are anti-symmetric about theEven signals are symmetric about the vertical

vertical axis.axis.

Eg. Sine waveEg. Cosine wave

7. Differentiate random and deterministic signal.

Deterministic Signal Random Signal

A deterministic signal is one in which thereA random signal is one in which there is a

is a certainty with respect to its values atuncertainty with respect to its values at any time.

any time. Future value of signals is predictable.

Future value of signals is unpredictable.Eg. Pulse train, sinusoidal wave etc.

Eg. EEG signal, Noise, Speech etc.

Deterministic signals can be expressed

Random signals are expressed mathematically inmathematically.

terms of impulses.

Page 46: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·3

8. Define fundamental period for a periodic DTsignal.

The fundamental period of No a DT signal x(n) is the smallest positive value of N for which x(n) =x(n + N) or

the DT signal exhibits periodically. It is defined as No = 211'm, where m is an integer value.no

9. Define fundamental period for a periodic DT signal.

The fundamental period of To a DT signal x(t) is the smallest positive value of T for which

x(t) =x(t + T) or the CT signal exhibits periodically. It is defined as To = 211'.COo

10. Is the signal x(t) = 2cos (3nt) + 7cos(9t) periodic?

Solution

x(t) = 2 cos (3m) + 7 cos (9t)

211' 211' 2co) =311', then 1i =-=-=-

COJ 311' 3

The given signal is said to be periodic if 1i must be rational.T2

1i 2 9 3T2 =3" x 211'=;; which is irrational.

Hence, the given signal is not periodic.

L

{t,11. Draw the waveform x( -t) and x(2 - t) of the signal x(t) = 0,

Solution

0:St:S3

t>3

x(t) x(-t)

3 3

-3 -2 -1 01:(2- t) I t~"'"---.--. .

-5 -4 -3 -2 -1 0

Page 47: Dsp Matlab & Two Marks

TQA·4 • Digital Signal Processing

12. VerifYwhether the following system is linear and time-invariant system y(n) = Ax[n] + B, where A and Bare constants.

Solution

y(n) = Ax[n]+B

Let us define x] (n) and x2 (n) as

x] (n) => y][n] = Ax}[n]+ B

x2 (n) => Y2[n] = AX2[n]+ B

Let us define x3 [n] such that

x3[n] = ax] [n] + bX2[n]

Y3[n] = AX3[n]+ B

Y3[n] = A[ ax] [n]+ bX2[n]]+ B

Y3[n] =aAx] [n]+ bAx2[n]+ B ::;:.ay] [n] +bY2[n]

Hence, it is non linear system.

Test for time-inva riant

Introduce time delay no in the input signal,

y][n] = Ax] (n-no)+ B

Introduce time delay no in equation (I),

y[n- no] = Ax(n-no)+ B

On comparing equation (1) and (2),

Hence, the system is time-invariant.

13. Find the energy of the discrete time signal

j( I)n

- n>Ox(n) = 2 ' -

3n ,n < 0

Solution

Let us consider (~r'n 2: 0

(I)

(I)

(2)

Page 48: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·5

~

E] = L(0.25tn=O

IE]=--=1.33

1-0.25

-I 2E2 = L 13nJ

n=~

~ 2

E2 = L[rnJn=l

~(I)nE2=L -n=l 9

IE2 =~=0.1251--

9

The total energy of the given signal, E = E] + E2 = 1.4583

14. What is the periodicity of the signal x(t) = sin IOOnt + cosl50nt?

Solution

Let xI (t) = sin 100nt where wI = lOOn

Let x2 (t) = cos 150n t where w2 = 150n

T =2n =~=~2 W2 150n 150

11 I 150 3-=-x-=-T2 50 2 2

211 = 3T2 = T = ~ is periodicity of the given signal.25

15. Find the overall impulse response of the causal system shown in figure below.

y(n)

Page 49: Dsp Matlab & Two Marks

TQA·6 • Digital Signal Processing

Solution

yen) =h1(n)+h3(n)x(n)

y( n) = ~ (n) + [h2 (n) - h1 (n) ] = h2 (n)x(n)

16. What are the basic continuous time signals? Draw any four waveforms and write their equations.

Solution

(i) Sinusoidal signal

x(t)

t x(t) = Asin(wt +<1»

(ii) Step signal

u(t)

{I, t;:::O

u(t) =0, « 0

o

(iii) Impulse signal

{I (=0J(t) = '

0, ( ;t 0

o

Page 50: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·7

(iv) Ramp signalr(t)

{ t, t~Or(t) =

0, t< 0

o

17. Classify the signals as

(i) periodic or aperiodic (ii) energy or power

(i) (a) x(t) = er:J.Ifor a. > 1

From the definition for a periodic signal,

x(t) = x(t + T)

e-u1 :# eU(I+T)

Hence, it is aperiodic

(b) x(t) = e-j2rrji

Since roo = 2nf, x(t) = e-jlJJo/

The condition for periodicity, T = 2nroo

(ii) (a) The condition for energy isT

2 2

E = Lt f ler:J.IidtT~~ T

2

T

2

E = Lt f e2a1dtT~~ T

2

T

E = Lt _1_[e2r:J.1 J2TT~~2a --2

E= Lt _1_[eaT_e-aTJT~~2a.

1 [~ -ooJE~ = 2a. e - e = 00

Hence, it is not energy signal.

Page 51: Dsp Matlab & Two Marks

TQA·8 • Digital Signal Processing

The condition for power signal is

7'

I 2

P =,Lt - f Ix(t)12 dt < 001-+~ r T

2

T

1 2 2

P = ,Lt - f leal I dt1-+~ r T

2

I [e2ot]f

p= Lt --T-+~ r 2a -7'

2

p = Lt _I_[euT -e-U7'J7'-+~2ar

p~ = 0

Hence, given signal is neither energy nor power signal.

(b) x(t) = e-1wot

T

2 . 2

E= ,Lt f le-1wotl dt1-+~ T

2

7'

2

E= Lt fidtT-+~ T

2

T

E= ,Lt [tFT7 ~oo __

2

E = Lt [!-. +!-.J7'-+~ 2 2

E= Lt [r]'l'~oo

E~ = 00

Hence, it is not energy signal.

Page 52: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·9

T

p= .u -!. j le-iClVl2 dt7~~T T

2

T

1 2

P=Lt~fldtT~~T T

2

T

P = T~t~ i[t ]~:c2

P = Lt J.. [!.. + !..Jr~~ T 2 2

P ~ =1

Hence, it is power signal.

18. Draw the waveform of x( -t) and x(2 - t) given

{t,x(t)=

0,

x(t)

0<t<3

t>3

xH) x(2 - I) = x(- 1+ 2)

3

2

o 2 3 -I -3 -2 -1 o

3

o

3

2 3

19. What is an energy signal? Check whether an unit step signal is an energy signal.

Solution

T

2

(a) A signal x(t) is said to be an energy signal if E = "Lt f Ix(t)j2 dt is finite, that is,7~<Xl r

2

Page 53: Dsp Matlab & Two Marks

TQA·10 • Digital Signal Processing

() {I, t ~O(b) x(t) = u t =

0, t < 0

Hence, it is not an energy signal.

It is a power signal.

T

2

E= Lt fWdt<ooT~oo 0

7'

2

E= Lt fldt7'~ooO

T

E = Lt [t]27'~00 0

E = Lt [!.-JT~oo 2

Eoo = 00

T

1 2

P = Lt - f 1 dtT~oo T 0

7'1 -

p= Lt -[tFT~oo T 0

P = Lt J.. [!.-JT~oo T 2

1p=-

2

Page 54: Dsp Matlab & Two Marks

20. Define and plot the following signals.'

Two Marks Questions and Answers • TQA·11

SignalMathematic R.latlonO•.•phlcal R.p •.••• ntetlon

r(t)Ramp

CT Signal L,r(t) =C'

I~ 00,

1<0

DT Signal

r(n)

{ n,

n~O 1Lr(n) =

0,n<O

1 2 nu(t)

Step

CT Signal C,C'

I~Ou(l) = 0,1<0

DT Signal

u(n)

C'

n~O

1wLu(n) =

0,n<O

12345 n

x(t)

Pulsal

CT Signaln,rectangularpulse

X(I) = { 1,

Id<L20,otherwise

DT Signal

2 0 2

-1'" TInl<~

u(n)

C' •u(n) = 0,otherwise

NON n

-2' 2'

Page 55: Dsp Matlab & Two Marks

TQA·12 • Digital Signal Processing

SignalMathematic RelationGraphical Representation

o(t)Impulse

CTSignal

1C'

I~O0(1) = O.

1",0tt = 0

DT Signal

o(n)

n~OB(n) = O.

n",O1

n

n=O

x(t)

x(t)

Exponential

CTSignal

k-lL-x(l) = ~. eexl

u > 1. exponential riseu < 1• exponential delay

DT Signal

tt

x(n) = ~ .un

x(n)x(n)£ ~

012

n n

x(t)

Triangular

CTSignal L,x(I)= (1-~.ltlsa

o .otherwise

DT Signal

- a 0 a

( 1- !!:!l.lnls a

x(n)

x(n) = a

Aoo . otherwise

- a 0 a

Page 56: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·13

21. The signals x(t) and y(t) are the input and output of an LTI system respectively as shown below.

Sketch the output response to following inputs:(i) x(t - 3) (ii) 2x(t) (iii) -3x(t) (iv) dx~t)

x(t) y(t)

-1 1 -1The output response y(t) indicate the system is an integrator.

x(t - 3) y(t - 3)

output•

0 12345 0123452x(t)

2y(t)

2

2

output

•-1

-3x(t)

- 3y(t)

-1

output •

-3 -3

22. What is meant by causality and stability? Derive the condition for the same.Solution

(a) A system is said to be"stable iff every bounded input produces a bounded output (BIBO).

Page 57: Dsp Matlab & Two Marks

TQA·14 • Digital Signal Processing

If the input signal is bounded, that is, Ix(t)1 :::;Mx < 00 for all t

Produces a bounded output signal, ly(t)l:::; My < 00 for all t then the system is called stable system.

(b) A system is said to be causal if the output response of the system at any time depends only on the presentand/or past output, but not on future inputs.

Example for causal is, y(n) = x(n) - x(n -1)

Example for anticausal is, y(n) = x(n) - x(n+ 1)

23. What is the total energy of a DT signal x(n) which takes a value of 1 at n = -1,0,1.

SolutionI

E= L 1112=12+12+12 =3n=-)

24. Is the following system invertible, y(t) = x2(t)?

Solution

For y(t) = x2(t)

y-I(t)=±x(t)

25. Test whether the system y(n) = n· x(n) is (i) linear (ii) time invariant.

Solution

i. y(n) = n· x(n)

The condition for linearity is that for an input signal,

(1)

Produces an output

x(n) = ax) (n)+bx2 (n)

y(n) = ay)(n)+bY2(n)

(2)

Let us define y](n) = nx](n) and Y2(n) = nx2(n)

Substitute equation (2) in (l),

y(n) = n[ ax) (n)+ bX2(n)]

= a·nxl(n)+b·nx2(n)

= a· y)(n)+b· Y2(n)

Hence, it is linear.

Page 58: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·15

ii. Introduce delay no in equation (1)

y(n)=n·x(n-no)

Now introduce delay to output equation

y(n- no) = (n- no) x(n- no)

Compare right hand terms of equation (3) and (4)

y(n):;ty(n-no)

The system is time-variant.

26. Find whether the following signal is periodic or not x(n) = 5cos(61r)n.

Solution

The condition for periodic is, N = 21r m, m = 1,2, ... for the given signal, 00 = 61r.00

21r ITherefore, N = - = - m

61r 3

Form=3, N= I.

Hence given signal is periodic with periodicity I.

I I27. Given y(n)=x(n)+-x(n-I)+-x(n-2). Find whether output signal y(n) is stable or not.8 3

Solution

According to stability condition, for a stable input signal,

Ix(n)1< Mx < 00 for all n produces stable output,

ly(n)1 S My < 00

1 1ly(n)1 S Ix(n)1+-lx(n-l)1 + -Ix(n- 2)1

8 3

(3)

(4)

l

Since x(n), x(n -1) and x(n - 2) are bounded input signal, hence produces an bounded output, that is,

Page 59: Dsp Matlab & Two Marks

TQA-16 • Digital Signal Processing

28. Perform addition and multiplication on the given inputs.

Solutionx,(t)

4

3

2

-4 -3 -2 -1

2

-4 -3 -2 -1 0

4

4

2 3 4

3

-4 -3 -2 -1 0

29. Find y(t) for the given signal.Solution

Given y(t) = x(3t +4)x(t)

3

4

2

Page 60: Dsp Matlab & Two Marks

y(t)=x(3t+4)

Two Marks Questions and Answers • TQA·17

I IIIIIIV

Lower

UpperLowerUpperLowerUpperLowerUpperbound

boundboundboundboundboundboundbound

31+4=0

31+4 = 131+4= 131+4=231+4 =231+ 4 = 331+ 4 = 331+4 =4

4

1=-1 1=-1 22111=01=--

1=--1=--1=--/=--3

3333

/ = -1.33

1= -0.661= -0.66/=-0.331= -0.33

y(t) = x(3t + 4)

3

y(t) = x(5t - 6)

I IIIIIIV

Lower

UpperLowerUpperLowerUpperLowerUpperbound

boundboundboundboundboundboundbound

5/ -6 =0

5/-6=15/ -6 = 15/ -6 = 25/ -6 =25/-6 =35/ -6 = 35/ -6 = 4

6

77889910/=-

/=-/=-/=-/=-/=-/=-/=-5

5555555

/ = 1.2

/=1.4/=1.4/=1.6/ = 1.6/ = 1.8/ = 1.8/ = 2

y(t) = x(St - 6)

3

2

o O.S 1

(1.2)

Page 61: Dsp Matlab & Two Marks

TQA·18 • Digital Signal Processing

y(t) = X(~-2)I IIIIIIV

LowerUpperLowerUpperLowerUpperLowerUpper

boundboundboundboundboundboundboundbound

~-2=O

~-2=1~-2=1~-2=2~-2=2~-2=3~-2=3~-2=43

3333333

1= 6

1=91=91= 121=12.1= 151= 151= 18

y(t) = x(t/3 - 2)

3

2

<Xl

2. IIi(n)1 < 00

flbnl=_1n=O I-b

o 2 4 6 8 10 12 14 16 18 20 22

30. Verify whether the systems are stable or not.

Solution

(a) h(n) = bnu(n)

The condition for stability is

The given system is stable if and only if Ibl < I.

(b) h(t)=t·sint u(t)

The condition for stability,..

J Ih(t)jdt < 001=-00

<Xl

J It·sintl dt1=0

Apply Bernouli's theorem ..

J t.sint.dt= t.(cost)l~ -l.(-sint)l~o

= -t cos tl~ +sin tl~ = 00

Hence, the given system is unstable.

Page 62: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·19

(c) h(t)=e-i21 u(t)

00 00

Jle-i211 dt= Jl dto 0

00

Jle-21! dt=tl~ =00o

The given system is unstable.

(d) y(n) = 4n-1 u(n - 2)

y(n) = 4n-1 u(n - 2)00

y(n) = L4n-1n=2

1 00

y(n)=-L4n4 n=2

y(n) =. .!.[~]= _i < 004 1-4 3

The system is stable.

31. Define memory system and verify whether the folIowing systems are memory or memoryless systems.

Solution

A system is said to be memory if the output of the system depends on past and/or future inputs.

(a) y(t) = x(t) + x(t + 1) Memory system

(b) y(t) = x3(t) Memoryless system

(c) y(t) = x(n -1) + x(1- n) Memory system

(d) y(n) = e./nu(n) Memoryless systems

32. Define a time-invariant system and verify whether the systems are time-invariant or not.

Solution

(a) y(t) = x(t -1) + 2t x(t - 2)

Introduce time delay to input signal alone,

y(t) = x(t -1-to)+ 2t x(t - 2-to)

Now, introduce time delay to output signal also

y(t - to) = x(t -1- to) +2(t - to) x(t - 2- to)

On comparing right hand terms of(1) and (2)

y(t):;t;y(t-to)

Therefore, the system is time-variant system.

(1)

(2)

Page 63: Dsp Matlab & Two Marks

TQA·20 • Digital Signal Processing

(b) yen) = x(n)cosam

Introduce time delay to input signal alone

yen) = x(n- no)cosron

Now, introduce time delay to output signal also

yen - no) = x(n- no) cosro(n- no)

On comparing right hand terms of (I) and (2)

y(n)¢y(n-no)

Hence, the system is time-variant.

(c) yen) = ex(n)

Introduce time-delay in input signal alone

yen) = ex(n-no)

Now, introduce time delay in output equation also

yen-no) = ex(n-no)

On comparing right hand terms of equations (I) and (2)

yen) = yen-no)

Hence, the system is time-invariant.

33. A pair of sinusoidal signals with common angular frequency is defined below.

xl(n) = sin 51t'n, x2(n)=.J3cos51t'n.

(a) Specify the condition which the period N of both XI (n) and X2 (n) must satisfy to be periodic.

(b) Evaluate the amplitude and phase, angle of the signaly(n)= xl(n)+x2(n)

Solution

N= 21t'm _.n 'wherem- 1,2,3, ...

(I)

(2)

(I)

(2)

L

Here n= 57r,

Ifm=5, 10, 15,20, .

then N= 2, 4,6,8, .

21t' 2N=-.m=-.m51t' 5

(b) The amplitude A and phase angle ¢ofthe signal, yen) = XI (n)+ x2(n) is

We would like to expressy(n) in the form Acos[On+q,].

yen) = Acos[nn+tJ>]

yen) = Acos(nn)costJ>- A sin(On) sin tJ>

Hint

cos (A + B) =cosAcosB-sinAsin B

(I)

Page 64: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·21

We know y(n)= x] (n)+x2(n)

y(n) = sin5rrn+.J3 cos5rrn

Compare equations (I) and (2), we get n = 5rr,

Asin~ = -I, Acos~ =.J3

Therefore, phase of the signal is given by,

,/, -I [sin~]'I'=tan --

cos~

~=tan-l[~]=_~

Similarly, the amplitude of the signal is given by,

A = ~[amplitude of x] (n)]2 + [amplitude ofx2 (n)]2

=~(1)2+(.J3i =2

The output signal y(n) can be expressed as,

y(n) = 2cos[5rrn-~]

34. Is it possible for an exponentially damped sinusoid to be periodic?

Solution

No, because exponentially damped sinusoidal will die-down to zero either at - 00 to 00. So, it cannot beperiodic.

35. Given y(n) = rn x(O), where r> I. Prove that system is astable.

Solution

Since rn is diverging for increasing values of n, the input is unbounded. Hence output is also not bounded.Theryfore, system is not stable.

36. The input and output of a diode are related by

I(t) = ao +aIV(t)+a2V2(t)+a3V\t)+ ...

where V(t) is applied voltage, I(t) is the current through diode, and ao, al are constants. Does this have

memory?

Solution

Since I(t) depends only on the present value of V(t), the diode does not have memory.

37. Write down the expressions of DT unit impulse and unit step functions.

Solution

Unit impulse function

{I, n = 08(n) =

0, n*"O

Page 65: Dsp Matlab & Two Marks

TQA·22 • Digital Signal Processing

Unit step function

{I, n ~ 0u(n) =

0, n< 0

38. Verify the stability and causality of a system with H(Z) = (3 - ;Z-l) 2(1- 3.5r + 1.5r )

Solution

H(Z)= (3-4rl)(1-3.5r' + 1.5r2)

H(Z) = Z(3Z -4)Z2 -3.5Z + 1.5

H(Z) _ Z(3Z -4)(Z -3) (Z -0.5)

H(Z) 3Z-4=-----Z (Z - 3)(Z - 0.5)

H(Z)=~+_B_Z Z-3 Z-0.5

A = H(Z)x(Z -3)1' = 2Z Z=3

B = H(Z)x(Z -2.5)1 = 1Z Z=2.5

H(Z) 2 1--=--+--Z Z-3 Z-0.5

Z ZH(Z) =2·--+-­Z-3 Z-0.5

2 1

H(Z)= 1-3Z + 1-0.5r1Taking inverse transform

hen) = 2(3t u(n) +(~ru(n)

By the definition of stability,

00

Ilh(n)l<oon=-oo

Page 66: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·23

"tlh(n~'~[23"+GJ]

n~lh(n)!=2~3n+ ~(~rSince 3n is divergent function, it is not bounded. Hence the system is unstable.

To prove causality, let us consider3-4Z-1 Y(Z)

H(Z)=-----=1-3.5Z-1 + 1.5r2 X(Z)

Y(Z)-3.5Y(Z)r1 + 1.5Y(Z)r2 = 3X(Z)-4X(Z)r1

Taking inverse transform

yen) = 3.5y(n -1) + 1.5y(n- 2) = 3x(n) - 4x(n-l)

The above system depends only on the present and past input and hence it is causal system.

39. Define static and stable system.

Static System A system is said to be a static or memory less system if the system output at any instant ndepends upon the input sample at the same instant n and not on the past or future input samples.

Example, yen) = x(n);y(n) = x2(n)

Stable System The given system is said to be stable ifand only if every bounded input produces a boundedoutput. The stable system is also known as "Bounded Input-Bounded Output" (8IBO).

A system is said to be stable if

Ix(n)!::; Mx < 00 for all n, then

Iy(n)! ::;My < 00 for all n .

40. Define Sampling Theorem.Solution

A band limited continuous time signal, with higher frequency 1m, can be uniquely recovered from its samples

provided that the sampling rate, F,. ~ 21m samples per second.

41. What is system function?Solution

Let x(n) and yen) is the input and output sequences of an LTI system with impulse response hen). Then thesystem function of the LTI system is defined as the ratio of Y(Z) and X(Z),that is,

H(z) = Y(z)X(z)

A system is said to be stable if every bounded input produces a bounded output.

42. What is the necessary & sufficient condition for causality?

Solution

The necessary and sufficient condition for causality of an LTI system is, its unit sample response hen)= 0 for

negative values of n, that is

h(n)=O, for n<O

Page 67: Dsp Matlab & Two Marks

TQA·24 • Digital Signal Processing

43. Define LTl and causality.

Solution

(i) Linear system A system that satisfies the superposition principle is said to be a linear system. Thesuperposition priniple states that the response of the system to a weighted sum of signals be equal to thecorresponding weighted sum of the outputs of the system to each of the individual input signals, that is,

H[axJ(n)+bxz(n)] = aH[(x\(n)]+bH[(xz(n)] for any arbitrary constants a and b.

Example, y(n) = nx(x)

(ii) Time-invariant system A system is called time-invariant ifits input-output characteristics do not changewith time.

Example,

(Hi) Casual system A system is said to be causal if the output of the system at any time n depends only onpresent and past inputs, but does not depend on future inputs. This can be represented as

Example,

y(n) = F[x(n), x(n -I), x(n - 2)...]

Iy(n)=x(n)+--

x(n-I)

44. Test whether the system y(n) = x(n) + nx(n -I) is linear or not.

Solution

y(n) = x(n) + nx(n -I)

Let xJ(n) and xz(n) are the inputs produces an outputs Yl(n) andY2(n) respectively.

y\ (n) = xj(n)+ nxJ (n-I)

yz(n) = xz(n)+nxz(n-I) .

The linearity is defined as

x(n) = axx\(n)+bxxz(n)

Substitute equation (2) in equation (1),

y(n) = axl(n)+bxz(n)+n[axJ(n-I)+bxz(n-I)]

= a[xJ (n) + axJ (n -1)]+ b[ xz(n) + nxz(n -I)]= ay\(n) +byz(n)

Hence the given system is linear.

1 I45. The input-output relation of a capacitor is v(t) =- J i( r) d r what is its memory?c -«;

Solution

It is the memory system with memory extending from t to - 00 •

(1)

(2)

Page 68: Dsp Matlab & Two Marks

Chapter 3 LTISystems

1. What is the linear convolution of two signals x(n) = {~, 3, 4} and h(n)= {f' - 2, I}?

Solution

x1(n)x2(n)x3(n)

,

,h1(n)

2,"3,", 4,,,,

,,

h2(n)

-4,,-~/' -~/',, ,, ,

,,,

h3(n)2, 3,,

~/,

,,,

y(n) = x(n) * h(n)

y(n)={2, -I, 0, -5, 4}

2. Define LTI system.

Solution

A system which satisfies the condition of linearity and time invariance is said to be a LTI system.

3. VerifY linearity, causality and time invariance of the system y(n + 2) = ax(n + 1)+ bx(n + 3) .Solution

Let us define xl (n) and x2 (n) as two signals, whose corresponding outputs are

y](n+2) = axl(n+I)+bx](n+3)

Y2(n+2) = ax2(n+ 1)+bx2 (n+3)

According to linearity,

x( n) = A x] (n) + B x2 (n )

Substitute equation (I) in system equation, that is,

y(n+ 2) = a [A xI (n+ 1)+ B x2 (n+ 1)]+b[Ax] (n + 3)+ B x2(n + 3)]

= A [ax] (n+I)+bxl(n+3)]+B[ax2 (n+I)+bx2(n+3)]

= A y](n+2)+BY2(n+2)

Hence, it is linear.

(1)

Page 69: Dsp Matlab & Two Marks

00

S(t) = f h(t) dto

TQA·26 • Digital Signal Processing

Test for causality

When n = 0, y(2) = ax(1) +bx(3)

Whenn=l, y(3)=ax(2)+bx(4)

System is non-causal as output signaly(3) depends on future input signal x(4).

Test for time invariance

Apply delay no to input signal only

ax(n-no +l)+bx(n-no +3)

Apply delay no to output signal

y(n-11o +2) = ax(n-no +2)+bx(n-no +3)

Compare right hand side of equation (1) and (2)

YI (n+ 2) = y(n-11o + 2).

Hence, given system is time invariant system.

00

4. Define convolution integral ofa system y(t) = f x('r)'h(t-T) dT.T=-eo

Solution

The above equation y(t) which is the weighted superposition of impulse response time shifted by T is

called convolution integral. This is represented as y(t) = x(t) '"h(t).

5. Check whether the system is time invariant or not.T

y(t) = f x(t) dt1=0

Solution

Introduce delay to to input alone, that is,T

y(t) = f x(t-to)dt1=0

Introduce delay to to output equation, that is,T

y(t-to)= f x(t-to)dt1=0

On comparing right hand terms of equations (1) and (2)

y(t)=y(t-to)

Hence given system is time invariant.

6. The impulse response of a system is h(t) = e-31 . Find its step response?

Solution

00

= f e-31 dto

(1)

(2)

(1)

(2)

Page 70: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·27

=-He-3II

Set) = - He -00 - eO] = ~

7. Find the system response when the system described by a differential equaion,

d2 yet) + S dy(t) + 6yet) = dx(t) + x(t), where x(t) = u(t) and initial condition are y(O+) = dy(O+) = I.dt2 dt dt dt

Solution

The homogeneous equation is,

d2 yet) + S dy(t) + 6yet) = 0dt2 dt

The standard homogeneous solutions are

Yn(t) = Ce).1

dYn(t) = CAe).1dt

d2Yn(t) = CA 2e).1dt2

Therefore, the homogeneous solution,

CA 2e).1 + SCAe).1+ 6Ce).1 = 0

Ce).1[ ,1.2 + SA+ 6] = 0

,1.2 +SA +6 = 0

The roots of the equation are AI = -2 and ,1.2 =-3

Therefore, homogeneous solution becomes

Yn(t) = C1e).l(+C2e"21

The forced solution to the given input signal x(t) = u(t) is

Yp(t) = C

Therefore, the differential equation becomes

dy~(t) +Sdyp(t) +6y (t)= dx(t)+x(t)dt2 dt p dt

O+SxO+6C=O+1

C=~6

Therefore,

(2)

(3)

Page 71: Dsp Matlab & Two Marks

TQA·28 • Digital Signal Processing

The complete solution is,

y(t) = Yp(t)+ Yn(t)

() C -21 C -31 1Y t = ]e + 2e +­6

Substitute t = 0,1

y(O) = C] +C2 +­6

Differentiate equation (4) and set t = 0

d:;t) = C] (-2e-21) + C2 (-3e -31)

dy(O) = -2C] - 3C2dt

substitute the initial Conditions in equations (5) and (6),

11 = C, +C2 +-

6

1 = -2C] -3C2

On solving equations (7) and (8)

(4)

(5)

(6)

(7)

(8)

Therefore,

8.

7 8C, =- and C2 =--2 3

() 7 _21 8 - 31 1Y t =-e -- e +-2 3 6

Find yet) for an RL circuit whose input is x(t) = e-51 and current through inductor at t = 0+ is

y(O+) = 2,1.

R

L

Solution

Apply Kirchhoff's voltage law to the given circuit.

x(t) = R yet) + L dy(t)dt

The homogeneous equation is,

L dy(t) + R yet) = 0dt

The solution to the homogeneous equation given in (2) is

Yn(t) = CeA1

(1)

(2)

(3)

Page 72: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·29

Substitute equation (3) in (2) "

L.C)..eA1 + RCeA' = 0

CeAt [LA.+R]=O

)..=_RL

The homogeneous solution is

Yn(t)=ce-(~}

The particular solution for the given input signal x(t) = e-si is Yp(t) = Ce-S'•

The particular equation becomes,

. dy (t)L-P -+RYp(t) = x(t)dt

L.C(-5e-S')+RCe-s, = e-si

-5LC+RC= 1

C(-5L+ R) = IC=_l_

R-5L

Therefore,

Yp(t) = _l_e-s,R-5LThe total solution is

y(t) = Yn(t)+ Yp(t)R

--I Iy(t)=Ce L + __ e-si

R-5L

Let/= 0,

y(O)=C+ R~5L =2 [y(0+)=2J. 1C=2--­

R-5L

The total solution is given by

( 1) _!!.t( 1 )y(t)= 2--- e L + --- e-si

R-5L . R-5L

9. Define Transfer function in CT systems.

Solution

Transfer function is defined as the ratio of output to input that is h (t) = y(t) .x(t)

(4)

(5)

(6)

(7)

Page 73: Dsp Matlab & Two Marks

TQA·30 • Digital Signal Processing

10. State the properties of convolution.

(a) Distributive property

x(n) * [hi (n)+ ~ (n)] = x(n) * ~ (n)+ x(n) * ~(n)

(b) Associative property

[x(n) * ~ (n)] * ~ (n) = x(n) * [~(n) * ~ (n)]

(c) Commutative property

hI (n)* ~ (n) = ~(n) * ~ (n)

Then,

x(n) * hen) = hen) * x(n)

x(t)

1t----..,11. Given x(t)and h(t) . Findy(t).

o

SolutionX(t)

o

(a) Fort<O,

00

J x( r) .h(t - r) dr = 0T=-OO

-t

h(t)

o

-1

(b) Forl>t>O(

y(t) = Jx(r)'h(t-r) dro

h(t-t)

(

yet) = J I dr = (r]~ = t _--'-_-'--~~,-----.r=O t

t

Page 74: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·31

(c) ForI~t~Oh(t - t)

1

yet) = f x(r)' h(t-r) dro

= (r)~=1

1

tt

(d) For2>t~1h(t-t)·

I

f x( r ) .h(t - r) dr = [rtl)-1

L

=[I-(1-t)]=t ~_-l-o---+t--+t

t

(e) For t> 2, yet) = 0

12. Compute the convolution of two sequences given and plot the output sequences.

x(k) h(k)

2

-k-2 -1

Solution

yen) = 0, for(n-2) =-3

i.e., y( -I) = 0

2

t(n-2)

2 3

1(n-2)

h(k-n)

2

-2 -1

4k

Page 75: Dsp Matlab & Two Marks

The relation between input and output is the transfer function of the LTI system.

Page 76: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·33

14. Find the linear convolution of x(n) = {I, 2, 3, 4, 5, 6} with h(n) = {2, - 4, 6, - 8} .

Solution

x(n)

h(nJ 2 3 4 5 6

2

-4

6

-8

y(n)={2, 0, 4, 0, -4, -8, -26, -4, -48}

~

15. Show that arbitrary CT signal xU) can be represented as x(t) = f x( r)·<5 (t - r) dr.

Refer the derivation of convolution integral.

16. What is the response of an LTI system for h(n) = <5(n) + 2·<5 (n -1) with an input x(n) = {I, 2, 3}.

3

2

x(k)

2

L..--~-...L-------_ko 2

L..--"'----------_ko

Page 77: Dsp Matlab & Two Marks

TQA·34 • Digital Signal Processing

Solution

h(-k)

2 2

h(1 -k) h(n -k)

2

-k k-k

-10 01 -2-10

tt t

n

n n

h(n-k)

h(n-k)

I n=2 I

I n=3 I

2

2

o 1

in

2k '----+--+--f----k

o 2

~

y(n) = L x(n)· h(n- k)K=O

(i) Forn<O,

(ii) Forn=O,

(iii) For n = I,

(iv) For n = 2,

(v) Forn=3,

(vi) For n > 4,

y(n) = 0 (no overlapping of datas)

y(O) = x( -1) h( -1) +x(O) h(O) + x(1) h(O) + x(2) + h(2)

y(O) = 0(2) +1(1)+2(0) +3(0) = 1

y(1) = x(O) h(O) + x(1) h(1)

y(1) = (1) (2) + 2(1) = 4

y(2) = x(O) h(O) + x(1) h(1) + x(2) h(2)

y(2) = 0 + (2 x 2) + (3 xl) = 7

y(3) = x(2)· h(2)

y(3)=3x2=6

y(n)=O

:. y(n) = {I, 4, 7, 6}

Page 78: Dsp Matlab & Two Marks

x(n)

h(n) 2 3

Two Marks Questions and Answers • TQA·35

yen) = {I, 4, 7, 6} verified.

17. Find the convolution of x(n) = {I, 2, 3, 4, 5} with h{n} = {I, 2, 3, 3, 2, I} .

Solution

x(n)

h(n) 2 3 4 5

2

3

3

2

yen) = {I, 4, 10,19,30,36,35,26, 14, 5}

18. Convolve xU) = e-z/u(t) with h(t) = u(t).

x(t) h(t)

o

Page 79: Dsp Matlab & Two Marks

TQA·36 • Digital Signal Processing

Solution

h(-t)

-t

(i) Fort<O, y(l)=O

(ii) For t;?: 0,

-t it

h(t-t)

o

h(t-t)

____ ---IL--_..l..-_ ...•.tit

1

y(l) = f e-21 dto

_ I[ -21 JI--- e

2 0

( ) 1 [-21 0Jy t = -2" e -e

= ~[I-e-21 J

y(t)

o

19. Find the reflected version ofx(t) about the amplitude axis.

Solution

x(t) x(- t)

{I for20. Find y(n) = x(n) +x( -n) . Given x(n) = -01 forfor

Solution

y(n) = 0 for all values of n.

n = 1

n=-ln = 0 and Inl > 1

Page 80: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·37

. {I for Inl = 121. Find y(n) = x(n) + x( -n) for x(n) = I Io for n = 0 and n > 1

Solution

22. Find y(n) = x(n + 3). Given

Solution

{2 for Inl = 1y(n) =

o for n = 0, Inl > 1

{I n = 1,2x(n) = 0-1 n = -1,-2n = 0, Inl > 2

{I for n = -I, - 2y(n) = 0-1 for n = -4, -5for n=-3, n<-5, n>+1

23. F;nd y(n) ~ x(2n+3). Given x(n) ~ tlSolution

n = 1,2

n=-I,-2

n = 0 and In! > 2

24. Given x(n)={~Solution

{I, n=-I

y(n) = -I n = -20, otherwise

-2 ~ n~ 2

h . . Find y(n) = x(3n-2).ot erwlse

{I, for n = 0, 1y(n) =

0, otherwise

{I, 0 ~ n ~ 925. Find the convolution of x(n) = anu(n) with h(n) =

0, n~ 0

x(k)

o 1 234 5k

h(k)

o 1 234 5 6 7 8 9k

Page 81: Dsp Matlab & Two Marks

TQA·38 • Digital Signal Processing

x(- k)

{U(k) = I, 9 ~ k ~ 0h(k) =

o otherwise

-5-4-3-2-10tn

ju. ,,-k, k:5 nx(n-k) =

0, otherwise

We know,

= =

y(n) = LX(k) h(n-k)= Lh(n)x(n-k)k=O k=O

For n <0,

x(n - k)

-1=

y(n) = L atl-k = 0k=O

k

tn

Since x(n - k), h(k) do not overlap.

For 9 ~ n ~ 0

"

y(n) = L a,,-kk=O

tI tI [I]k= atl L a -k = an L -

k=O k=O a

y(n) = a"(I ).n+l

1- ­aII--a

x(n - k)

-2-1 0 1

Page 82: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·39

For n> 9

x(n-k)

9

y(n) = I,an-kk=O

-2-2-2-2-10 1 2 3 4 5 6 7 8 9 1011 12

tn

9 (l)k=anI, -k=O a

k

y(n) = an

26. Find the convolution of the following sequences.

(i) x(n) = u(n), h(n) = u(n - 3)

l-(~rl-i.

a

x(k)

L..---.1._...J-_.L-----J ko 234 5

h(k)

OL..----2--3.1.----I.4-....J5L..--.L6--7- k

For (n-3)<0,

y(n) =0

There is no overlapping of sequences

-k

-6 -5 -4 -3 -2 -1 0

Page 83: Dsp Matlab & Two Marks

TQA-40 • Digital Signal Processing

h(n-k)

For (n - 3)~0,n

y(n) = L 1n=O

y(n) = (n+ I) ___ .L---1_...l----JL..----L_..J... k-3 -2 -1 0 2 3 4

t(n-3)

(ii) x(n)={1,2,-I,I} h(n)={I,O,I,I} perform convolution.

x(n)hn 2-1

o

x(n)

y(n)= {I,2, 0, 4, I, 0, I}

27. Explain basic laws of convolution.

Solution

Commutative law of convolution

y(n) = x(n) * h(n) = h(n) * x(n)

ht(n)*~(n) = ~(n)*ht(n)y(n) x(n) y(n)

x(n)

Associative law of convolution

[x(n) * fit (n)] * ~ (n) = x(n) * [fit (n) * h;. (n)]

y(n) x(n) I I y(n)•• • h(n) = h1(n) • h2(n) --~

x(n).(h(n)+ h(n)] = x(n).h(n)+ x(n). h(n)

28. Analysis equation of DFT ?Solution

Analysis equation of DFTN-l

X(k) = L x(n)e-jWn, k = 0,I,...,N-In=O

Page 84: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·41

Synthesis equation of DFT,

1 N-) .

x(n)=- L X(k)eJwn, n=O,I, ... ,N-IN k=O

11, n = -2, 0, I

29. Obtain the convolution of x(n) = 2, n = -1 and h(n) = c5(n) -c5 (n -1) +c5 (n - 2) -c5 (n - 3)

0, elsewhereSolution

i.e. x(n)={I, 2,1, I}; h(n)={I, -1, 1,-I}t tThe convolution sum y(n) = x(n) * h(n)

~h(n

1211,

, ,,,,

,1

12,,1,,

1,",

,, ,, ,, ,,

-1-1,-2,-1,-1,,, ,, ,,

, ,,,,

, ,,, ,1 1,2 1, 1,, ,,, ,, ,,,

, ,,, ,-1

,-1 -2,-1,,- 1, , ,,

y(n) = x(n) * h(n)={ 1,0, 1,-2, 0, -I}

30. Explain convolution procedure?

Solution

(a) Plot the given signal x( T) and impulse response h( T)

(b) Obtain h(t-T) by folding h('r) and T=oandshiftingbytimet.

(c) Multiply signal X(T) and impulse response h(t - T) and integers over the overlapped area to obtain y(t)

(d) Increase the value t such that the function of X(T) and h(t -T) changes. Calculate y(t).

(e) Repeat step (c) and (d) for all intervals

(t) Commutative of signal X(T) and impulse response h(T) is also valid.

31. Find the complete solution of the given difference equation y(n) = 7y(n -1) -I2y(n - 2) + 2x(n) - x(n - 2)

where x(n) = u(n).

Solution

y(n) = 7y(n -1) -I2y(n- 2)+ 2x(n) - x(n - 2)

The complete solution is sum of natural and forced solutions

(I)

y(n) = Yn(n) +Yl (n)

The natural response can be obtained by setting input signal x(n) is zero. Then equation (1) becomes

homogeneous equation, that is

y(n)-7y(n-I)+ I2y(n-2) = 0 (2)

Page 85: Dsp Matlab & Two Marks

TQA·42 • Digital Signal Processing

The solution to the homogeneous equation becomes

Substitute equation (3) in (2)

).,n_7).,n-] + 12).,n-2 =0

).,n-2[).,2 -7).,+12 ]=0

).,2-7).,+12=0

The roots of the equation are A) = 4 and ,12 = 3.

The homogeneous solution is

Yn(n) = C'4n + C2 '3n

The forced solution can be obtained by considering its input signal x(n) = u(n).

y(n) -7y(n-1)+ 12y(n - 2) = 2x(n) - x(n- 2)

The particular solution to the signal, x(n) = u(n) is K

yp(n) = K

Substitute equation (6) in (5)

K-7K+12K=2-1

K='!"6

(3)

(4)

(5)

(6)

Therefore,

The complete solution,

Letn=O,

Put n = 1,

1

yp(n)="6

y(n) = Yn(n) + yp(n)

n n 1y(n)=C)4 +C23 +-

6

1y(O) = C) +C2 +­

6

1

y(l) = C]4+ C23+"6

y(O) can be obtained by substituting n = 0 in equation (1)

y(O) = 7y( -1) -12y(-2) +2x(0) - x{ -2)

y(0)=0-0+2-0=2

Since intial conditions are not given, all intial condition are assumed to be zero.

Page 86: Dsp Matlab & Two Marks

Similary, putn=I,

The complete solution is,

Two Marks Questions and Answers • TQA·43

y(l) = 7y(0) -I2y(-l)+ 2x(l) - x(-I)

y(l) = 7x2-0+ 2-0 = 161

2=Cj +C2 +-6

116 = 4Cj +3C2 +­

4

2

8 = 4Cj +4C2 +3

116 = 4C) +3C2 +­

4-----5

-8=0+C2 +­12

C =.!Q!.2 12

11C) +C2 =­6

11C( =--C2

6

II 101=---6 12

C _ 35j - 12

() 10 I4n 353n 1y n =- +- +-12 12 6

Page 87: Dsp Matlab & Two Marks

Chapter 4 Fourier Series

1

1. Determine the signal x(t) whose fr~quency roo = 2n and coefficients are ao = 1, a_I = al = '4'1 1 1

a_3 = a3 = 6' a_s = as = '8 and a_7 = a7 = u·Solution

00

x(t) = L akejkroolk=-oo

7

= L akejk31r1k=-7

= a_7e-.i7(31r1) + a..(,e- j6(31r1) + a_se- jS(31r1) + a-4e- j4(31r1) + a_3e- j3(31r1) + a_2e- j2(31r1)

+a_1e- j(31r1) + ao + ale.i(31r1) + a2ej2(31r1) + a3e.i3(31r1) + a4ej4(31r1) + asejS(31r1)

+a6e.i6(31r1) + a7ej7(31r1)

= /Je.i211r1+e-.i211r1]+i[e.ilS1r1 +e-}S1rI]+~[ej91r1 +e-j91r1]+~[ej31r1 +e-j31r1]+1

1 1 1 2= 1+ -cos 3nt + -cos 9nt + -cos 15nt + -cos21nt

2 3 4 11

2. Find the Fourier series coefficient (trignometric representation) of the given signal.

x(t) x(t)

3

2

Solution

27t

(1tI2, 1)

2t n- O<t<­n' --2

x(t) =1,

2,

n-~t~n2

n ~ t ~ 2n

x(t}-O 0-1---=t-O 0-n/2

2ty=­n

Page 88: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA-45

. 110+7'

ao = T J x(t) dt10

[~ j

I 2t ~ 2~=- J-dt+ Jldt+ J 2dt2n 0 n ~ ~

2

[~ 1

2 -I 2 t 2 ~ 2~

=- --I +tl +2·tl2n n 2 ~ ~o 2

= 2~[H(I)' -oH '-I)+2(2'-'l]

ao =_I_[~+~+2n]=!!2n 4 2 8

210+7'

an = T J x(t)cosncoo(t) dt10

Here T = 2n and COo = I

[~ j

2 "2 2t ~ 2~

an =- J- cosnt dt +Jcosnt dt +2J cosnt dt2n 0 n ~ ~

2

[ { ~} . ~ . 2~]

I 2 I . 2 Smnt SIOnt

=- - -2 (cosnt+ntslOnt)l· +--1 +2--1nnn 0 n~ n~2

I [ 2 {( n n. nn) o} 1( . . nn) 2( . 2 . )]=- -- cos-n+n-slO- -COS +- slOnn-slO- +- sm nn-smnn

n n2n 2 2 2 n 2 n

I [ 2 ( nn nn. nn ) I . nn]=- - cos-+-slO---1 --sm-n nn2 2 2 2 n 2

2 [ (nn) nn. (nn) nn. (nn)]=-- cos - +-sm - -I-sm -

(nn)2 2 2 2 2 2.

2 ( nn ) I [ 2 ( nn nn. nn ) I . nn]= (nn)2 cosT-I =; nn2 cosT+TSInT-I -;;SInT

2 [ (nn) nn . (nn) nn. (nn)]= (nn)2 COST +7SIO T -ITSIn T

2 ( nn )= (nn)2 cosT-I

Page 89: Dsp Matlab & Two Marks

TQA·46 • Digital Signal Processing

21,,+7'

bn = T f x(t) sin nroot dtI"

Iri2t rr 2rr 1= - f - sin nt dt +f sin nt dt + f 2sin nt dt

rr 0 rr rr rr

2

=-.!.[3-[_1 (sinnt-ntcosnt)]i +[_ cosnt]rr +2[- cosnt]2rr]rr rr n2 0 n!: n rr

2 .

= -.!.{2.[sin nrr _!!!!.-cosnrro]_ '!-[cosnrr - cos nrr]_3-( cos 2rrn - cos nrrl}rr rrn2 2 2 2 n 2 n

=-.!.{2.[sin nrr _ nrr cos nrr]_.!-[(_It -cos nrr]_3-[I_(_ltJ}rr rrn2 2 2 2 n 2 n

I [2 . nrr I nrr (_I)n I nrr 2 2 n]= - --sm - - -cos- - --+ -cos- - - + -(-I)

rr rrn2 2 n 2 n n 2 n n

I [2 . nrr 2 I n]=- -sm---+-(-I)

rr rrn2 2 n n

3. What is Fourier representation?

Solution

The studyof signalsand systemsusing sinusoidalrepresentationis termed as Fourier analysis.The representationof the signal as a series is termed as Fourier series.

00

x(t) = L ake-JkaJolk=-oo

Hint sin A cos B = .!-[sin(A- B) + sin(A+ B) 12

2rr

4. Find the Fourier series of the signal x(t) = f sin2rrfomt·cos2rrfont droot where m and n are integers.o

2rr

Solution x(t) = f sin 2rr/omt·cos2rrfont dto

Let 2rr10 = Wo

hIx(t) = f -[sinwo(m-n)t+sinwo(m+n)t] droot

02.

I2rr I 2rr

= - f sin roo(m - n)t droot + - J sin roo(m + n)t dwot2 0 2 0

Page 90: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·47

= ~[COS COo(m - n)t ]2rr + ~[COS COo(m + n)t ]2rr2 (m - n) 0 2 (m + n) 0

= ~[COS(m - n)2n - COSO] + ~[COS(m + n)2n - COSO]2 (m-n) 2 (m+n)

xU) = ~[O]+~[O] = 02 2

5. Find the Fourier series for the periodic signal x(t) = t, O::S;t::S;1 and repeats every 1 second.

SolutionX(t)

-3 -2 -1 0 2 3

T = I sec, therefore,I

ak = f te-.ikrool dto

2nWo = - = 2n

TI

ak = f te-.i2Trkt dto

For k= 0,

I 211

ao = ftdt=!'-o 2 0

1 1ao =-[1-0]=-2 2

For k :;t: 0,

I

ak = f te-J2rrkl dto

ak = _.I_e-J2rrkt (- j2nkt _1)11-}2nk 0

ak =_-.-I_[e-.i2rrk(-j2nk-l)+IJ}2nk

Hint

Page 91: Dsp Matlab & Two Marks

TQA·48 • Digital Signal Processing

6. A signal x(t) = cos 21l' ft is passed through a device whose input-output is related by y(t) = x2 (t). What

are the frequency components in the output?

Solution

y(t) = x2(t)

1+ cos41t"ft=----2

1 1= -+-cos41t"ft2 2

1 cos41l' ftThe frequency components are: DC component is "2 and AC component is 2 .

Page 92: Dsp Matlab & Two Marks

Chapter 5 Fourier Transform

I. Find the DTFT of x(n) = (~ru(n) and plot its spectrum.

Solution

x(n)=(~r u(n)

The DTFT is given by00

X(eIW) = L x(n)e-IWnn=-<X:l

~ (I)n -jwn= ~ - e·. n=-oo. 2

00 (e-.iW)n=L -

n=-oo 2

2=---=---

The magnitude is

Ix(eIW)1 = 22-(cosw- jsinw)

I Iw I 2X(e ) =------(2 - cosw) - jsin w

IX(eIW)1 = 2J(2-COSW)2 +(sinw)2

The phase angle is arg [X (eIW)J = _ tan -I [ sin w ]2 -coS(j)

2. Find 8-pointDFTof x(n) = [1,-1,1,-1,1,-1,1,-1]

Solution

. N-I _.}1rnk

x(k)=Lx(n)e N ,k=O,I, ... ,N-In=O

Page 93: Dsp Matlab & Two Marks

TQA·50 • Digital Signal Processing

For N=8,

7 _ j7!..nk

x(k)= Lx(n)e ·4 , k=O, 1,...,7 .n=O

k= 0,

7

x(O)= L x(n) eOn=O

=1-1+1-1+1-1+1-1=0

k= 1,

7 .1r-J-nx(l)= Lx(n)e ·4 = 0

n=O

k= 2,

7 _ j7!..2n

x(2) = Lx(n)e 4 =0n=O

k= 3,

7 _ j7!..3n

x(3) = L x(n)e . 4 = 0n=O

k= 4,

7 _ j7!..4n

x(4) = Lx(n)e 4 =8n=O

k= 5, .

7 _ j7!..sn

x(5)=Lx(n)e·4 =0n=O

k= 6,

7 _ j7!..6n

x(6)=Lx(n)e·4 =0n=O

k= 7,

7 -/!-7nx(7) = L x(n)e 4 = 0

n=O

x(k) = [0, 0, 0, 0, 8, 0, 0, 0]

Page 94: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·51

3. Distinguish between Fourier series and Fourier transform.

Fourier Series Fourier Transform

All periodic signals have Fourier series

All aperiodic signals have Fourierrepresentation.

transform.

A periodic and continuous-time signals

An aperiodic and continuous-time signalshave continuous-time Fourier series

have continuous-time Fourier transform.

representation. A periodic and discrete-time signals have

An aperiodic and discrete-time signalsdiscrete-time Fourier series representation.

have discrete-time Fourier transform.

4. Determine the impulse response of the continuous-time system described by the differential equation

d2 y(t) dy(t) dx(t)--2-+4--+3y(t) = --+2x(t) using Fourier transform.

dt dt dt

Solution

d2y(t) +4 dy(t) +3y(t) = dx(t) +2x(t)~2 ~ ~

Apply Fourier transform,

(j(J)2 Y(j(v) + 4(j(J) )Y(j(J) + 3Y(j(J) = (j(J) )X(j(J) + 2X (j(J)

Y(j(J)[(j(J)2 +4)(J)+3 ]=X(j(J) [)(J)+2]

Y (j(J) )(J) + 2

X(j(J) = (j(J)2 +4)(J)+3

Y(j(J) _ H(' ) _ )(J)+2--- - J(J) - ------X (j(J) (j(J) + 1) (j(J) + 3)

A BH(j(J) = ---+---

(j(J)+ 1) (j(J)+3)

A = (j(J) + 1) H(j(J)ljw=_l

A=-1+2=.!..-1 +3 2

B = (j(J)+3) H(j(J)ljw=_3

B= -3+2 =.!..(-3 + 1) 2

1 1

H(jm) = _2_+_2_)m+ 1 )m+3

The impulse response is given by

h(t) = ~[e-'u(t) + e-3'u(t) ]

Page 95: Dsp Matlab & Two Marks

TQA·52 • Digital Signal Processing

5. Compute the 8-point DFT of x(n) = {0.5, 0.5, 0.5, 0.5, 0, 0, 0, O}. Using in place radix -2 DIT algorithm.

Solution

Calculation of Weightages

Stage I:

Stage 2:

Stage 3:

wZ =14

o WI.W =1 N =-j!!.. and-2 2

W~ =1

W~ = 0.707 - jO.707

W2 .N =-j

wl = -0.707 - jO.707

Input sequence in bit reversal order

xr(n) = {0.5, 0, 0.5, 0, 0.5, 0, 0.5, O}

Page 96: Dsp Matlab & Two Marks

-l ~ o :s::

l» ~ ,...

<II o c: CD !!i o' ::J <

II l» ::J a. > ::J <II ~ ~ en

x(5

)=

~.5

-12

.07

x(4

)=0

x(6)

=0

x(7

)=0.

5-

1.20

7j

x(3

)=

0.5

+'P

.207

x(2)

=0

x(0)

=2

x(1

)=0.

5+

1.20

7j

x(0

)=0.

5

0.5

x-.,

x(4

)=0

•""

'/-0

.5+

0.5j

W~

=1

-14

0.5

x(2)

=0.

5

/'\.

/'\.

0"'

?". •·

W~

=1

x(6

)=0

/.,,>

-0.5

4"

/'\.

••

-0.5

-0.5

j

W~

=1

-1W

~=

-j-1

4

,.-

0.5

x(1)

=0.

5"

? ·

.w

~=

1

x(5)

=0

-0.5

-0.5

+0.

5j

W~

=1

·-1

·w

~=

0.70

710.

707

4

0.5

·x

(3)=

0.5

·0

·

W~

=1

W~

=-j

·.-

x(7)

=0

-0.5

-0.5

j

W~

=1

-1-{

).5 W

~=

-j-1

W~

=-

0.70

710.

707

••

-1

4"

• !I

Page 97: Dsp Matlab & Two Marks

TQA·54 • Digital Signal Processing

6.(i) State and prove Parseval's relation for Fourier transform.

Statement Parseval's relation states that the total average power in a periodic signal x(t) equals the sum of theaverage power in individual harmonic components which in turn is equal to the squared magnitude of Fouriertransform.

00 00

f Ix(t)12dt = _1 f Ix{jro)12 dro21T-co -co

Proof If x(t) and X(jro) are the periodic signals and its Fourier transform, then the average power of a

periodic signal is given by00 00

f Ix(tt dt = f x(t) X· (t) dt-co -co

[ ].00 1 0 .

= 1x(t) 21T1X{jro)eJro/ dro dt

= 2~Ix'(j"'{I x(/,,1'" d}'"00

=_1 f X·{jro)·X{jro) dro21T-co '

00 00

f Ix(t)12dt = _1 f Ix{jro )12 dro21T-co -co

Thus proved.

(ii) State and prove convolution property for Fourier transform.

Statement x(t)* y(t) ( Fouriertransfonn ) X{jro) Y{jro)

The convolution of two signals in the time is equal to their products in the frequency domain.

Proof By definition of convolution the output response of the system is the shifted multiplication of systemresponse and input signal is

ro(t) = x(t) * y(t)

00

= f x(r)y(t-r) dr-co

The Fourier transform of ro(t) is given by00

W{jro) = f ro(t)e-jro/ dt-co

=I[I x{<) y(/-T) dl1'" dt00

= f x(r)[f y(t-r)e-jro/ dtJ dr-00

Page 98: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·55

Let t' = t- r

t = t' + r

dt = dt'

00 00

= J x(r)e-jroT dr J y(t')e-jrot' dt',

X(jro)

:. W(jro) = X(jro) Y(jro)

Y(/ro)

Thus proved.

7. Find the response of an LTI system with h(n) = {I, 2} and x(n) = {I, 2, I} using DIT-FFT algorithm.

Solution

Let us find the 4-point FFT for x(n) and h(n)

We know y(n) = x(n) * h(n)

or Y(k) = X(k)H(k)

(i) Hence first find the 4-point FFT ofx(n), h(n)

(ii) To obtain Y(k) find their product

(iii) To obtain y(n) find inverse FFT of Y(k)

To find 4 point FFT of x(n) = {I, 2, I} using DIT algorithm, append '0' at the end as Let x(n) = {I, 2, 1, O}.

Writing in bit-reversal order.

xr (n) = {I, 1, 2, O}

x(O) = 1

2X(O) = 4

x(2) = 1

0X(1)=-2j0 WN =1

-1

x(1) = 2

"22 X(2) = 00 WN=1

x(3) = 0

2X(3) = 2j

Wti =1

-1W~=1-1

2

Let us now find the 4-point FFT of h(n) = {I, 2}

Now h(n) = {I, 2, 0, O}

Writing in bit-reversal order

hr (n) = {I, 0, 2, O}

Page 99: Dsp Matlab & Two Marks

TQA·56 • Digital Signal Processing

H(2). -1

H(1) = 1 - 2j

H(3) = 1+ 2j

H(O) = 3h(O)= 1

h(2) = 1

0-1W!:i =1

h(1) • 2

2 2

0WN =1

h(3) = 0

20

-1 W~ =j-1W!:i =1

2Y(k) = X(k) H(k)

={4, -2j, 0, 2j} {3, 1-2j, -I, 1+2j}

Y(k) = {12, -4-2j, 0, -4+2j}

To find the IFFT,take conjuagate ofY(k),

Y·(k)={12, -4+2j, 0, -4-2j}

Writing in bit-reversal order

Y·(k) = {12,0,-4+2j, -4-2j}

1212

0

12

0-1W!:i =1

-4+2j

2

-4-2j

0-1

WN =1"'2

W1 .N =J

4

16

20

8

y(n) = 2-{4, 16, 20, 8}N

1=-{4, 16, 20, 8}={1, 4, 5, 2}4

8. Find the DTFT of h(n) = (~ru(n). Also determine its phase and magnitude.Solution

<Xl

H(ejro) = L h(n) e-jronn=--<X1

<Xl (I)n .= L - u(n) e-}ron

n=-oo 5 Hint

<Xl 1

Lan=-o 1- a

Page 100: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·57

. 1H(e!w)=---

1 1 - jw--e·5

=----1- 0.2e- jw

Magnitude is given by

iH(ejW)1 = . 1~(l-0.2coswi +(0.2sinw)2

1

- ~[I-0.4COsw+0.4cos2 w+0.4sin2 wJ

I . I 1H (e!W) = ---;=======.JI + 0.4 - 0.4 cos w

I . I 1H (e!W) = ---;=====-.J1.4 - O.4cosw

Phase is given by

IH( IW) -1 [Imaginary term]e· = - tan -----

~-- Real term

IH( IW) -I ( 0.2sinw ). e· =-tan ----~-- I-0.2cosw

9. Find the Fourier transform of 8(n) - 8(n -1). Find its magnitude and phase.

Solution

Given 8(n)-8(n-I)=h(n).<Xl <Xl

H(ejW) = Lo(n)e-jWn - Lo(n-I)e-jWn

= I-e-jw

The magnitude is given by H(e!w) = 1-[cosw - jsin w]

= I-cosw+ jsinw

IH(ejW)1 = ~(l- cosw)2 + (sin W)2

= ~I- 2cosw+ cos2 w+sin2 w

Hint

e-jW = cosw - jsin w

Hint

cos2 8+sin2 8 = 1

Hint

o(n) = Iatn = 0

o(n-l) = Iatn=I

and both are '0' elsewhere

Page 101: Dsp Matlab & Two Marks

TQA·58 • Digital Signal Processing

The phase is given by,

iH(ejW)1 = )4sin2 ;

IH(ejW)1 = 2sin ;

iH( fW) -I sincoe· =tan --­~--- I-cosco

Hint

sin2 8 = _1_-_co_s_2_82

Hint(I)

IH(ejW) = cot ~

IH (ejW) = tan ( 90 - ; )

Substituting equation (2) in (I)

IH(ejW) = tan-1 {tan [90- ;]}

. 2 . co cosmco = sm-cos-2 2

1- cos co = 2 sin 2 co

2 (2)

I· co 1f coH(eJW) = 90-"2 =2"-"2. 1

10. Determine H(eJW) for y(n)+"4y(n-l)= x(n)-x(n-I). Plptthe magnitude and phase response.

Solution

1 .y(n) +-y(n -I) = x(n)- x(n-l)

4

Y(eJW) + .!.e-.JwY(e.JW) = X(ejW)- e-Jw X(e./W)4

Y( ejW) [I +± e- joo ] = X ( ejoo ) [ 1- e- joo ]

l....r-e - ./00

1 1 -joo+-e4

H(ej(JJ) = I-cosco+ jsinco1 1 1 . .+-cosco-·- }smco

4 4

Magnitude is given by

(I)

~(l-cosco)2 +sin2 co

(I+±COSCOr +(±sinco r

Page 102: Dsp Matlab & Two Marks

Two Marks Questions and Answers • fQA·59

.Jl +ooS2(t)-2~sco+sin2 co=

11 2 1 1'2+ -cos OO+-COSOO+ -sm 0016 2 16

Hint

cos2 co + sin2 co = 1

Hint

1- cos 200 • 2---- =- sm 00

21- cos 200 = 2sin2 00

1- cos 00 = 2 sin2 002

2( 2sin2 ~)

17 1-+-COSOO16 2

= ";2 - 2 cos 00

1 11+- +- cos 00

16 2

1H (ejOJ)1= .J2(l- cos (0)17 1-+-COSOO16 2

2 . 00sm2

17 1-+-COSOO16 2

Phase is given by,

IH (ejOJ) = tan -1 [ Imaginary part ]------ Real part

Let us consider the real and imaginary parts of numerator term of equation

[2 . 00 00]

[.] sm-cos-tan-I smoo = tan-1 2 2

1- cos 00 2 . 2 00sm -2

(1)

= tan-1 [cot i]

=90-~2

Let us consider the real and imaginary parts of denominator term of equation (1)

[ 1. ]

--smoo= tan-l_4~ __

l+icOSOO

(2)

(3)

Page 103: Dsp Matlab & Two Marks

TQA·60 • Digital Signal Processing

The equation (2)and (3) can be rewritten as follows to obtain the phase information.

:.iH(ejW)=90- co-tan-1 [ -o.25sinco ]._-- 2 1+0.25 cos co

. 2sin w!H(e)W)=90-W-tan-1( -o.25sinw)

wIH(eJW)I= 2

~~~+ O.5cosw

2 1 + O.25cosw

0

0 0.511'

11'

0.636 0.42211'-

4

11'

1.372 0.32811'-

2

311'

2.195 0.19211'4

11'

2.666 0

2.5

2.0

1.5

1.0

0.5

Magnitude Spectrum

ro

2.5

2.0

1.5

1.0

0.5

Phase Spectrum

oIt

4

It

231t

41t o

It

4

It

2

31t

4It

11. Determine the magnitude spectrum and energy spectral density of a1nl where Inl = {:~,Solution

00

X(ro) = I. x(n)e-jWnn=-oo

-1 00

= I. a-n e-./wn +I. an e-jwn-00 0

00 00

= I. an e./wn +I. an e-./wnI 0

n~O

n<O

Page 104: Dsp Matlab & Two Marks

Leta=0.5

Two Marks Questions and Answers • TQA·61

<Xl <Xl

= L(a.ejrot + L(a.e-jrot1 0

aejro - a2 + 1- aejro=-------1- ae- jro - aejro + a2

l-a2

= 1- a [ ejro +e- jro ] + a2

X(ro) = l-a21- 2a cos ro + a2

aJ Magnetic spectrum Energy Spectral Density

IX(aJ)1d xx(w) = Ix(w)12

0

l-a2

IX(w)12 =C+arX(ro) = 1- 2acosO + a2

I-a

l-a2

l+a =9==--

1-2a+a2 I-a

Since a = 0.5X(w) = 1+0.5 =3

1-0.5±1!'X(ro) = 1- a2

IX(aJ)12 = e-=~r1- 2acos1!'+a2

l+a

l-a2

= 0.11= 1+2a+a2

= I-a = 0.33

l+a±21!'

l-a2IX(ro)12 = 9X(ro) = 1-2acos21!'+a2

l-a2

= 1-2a+a2

=1+a=3I-a

Page 105: Dsp Matlab & Two Marks

TQA·62 • Digital Signal Processing

- 31t -21t -1t o 1t 21t 31t

12. Compare linear and circular convolution.

S. No.Linear Convolution Circular Convolution

1.

It can be used to find the convolution ofOnly for OT signalsboth CT and OT signal 2.

Can be performed on finite & infiniteCan be performed only on finite sequencesignals/sequences 3.

Length ofx(n) and hen) need not be Length ofx(n) and hen) has to be equal.equal

The length of the sequence with minimumlength is increased by appending with zeros4.

Ifx(n) is oflength Land hen) is of lengthHere the length of yen) will beM then yen) will have a length of

N = Max(L,M)N=L+M-)

5.Can be used to find the response of aCan be used to find the filter response only

filterafter zero padding

6.Methods of finding linear convolutionMethods of finding circular convolution

(i)graphical method (i)circle method

(ii) matrix method(ii) matrix method

(iii) cross table method(iii) OFT-10FT method

13. How can we obtain linear convolution from circular convolution?

Solution

Letx(n) have a length of Land hen) have a length of M. Increasing the length ofx(n) and hen) to L + M -I and

then performing circular convolution on them results in an output which is same as performing linearconvolution on x(n) and hen).

14. Prove the above concept with a suitable example.

Solution

Let x(n) = {I, 3, 5, 7}; hen) = {I, 2, I}

yen) = x(n) * hen). Let us find the linear convolution using cross table method.

Page 106: Dsp Matlab & Two Marks

x(n)

h(n) 3 5

Two Marks Questions and Answers • TQA·63

y(n) = {I, 5, 12, 20, 19, 7} (1)

where length of y(n) is 4 + 3 - 1 = 6.

Using Circular convolution

First increase the length of x(n) and h(n) to L + M -1 = 6.

x(n) = {I, 3, 5, 7, 0, O}; h(n) = {I, 2, 1,0,0, O}

Using Matrix method

1000121 1

2

100013 5

1

21000512

0

12100720

0

012100 19

0

001210 7

y(n)={I, 5, 12, 20, 19, 7}Equation (1) and (2) is thus proved.

(2)

15. What is zero padding? What are its uses?

Solution

1. Let the sequence x(n) have length L. If the N point OFT (N) L) of the sequence x(n) is to be found,(N -L) zeros are to be added to the sequence x(n). This is known as zero padding.

2. The uses of padding a sequence with zeroes are

• We can get "better display" of the frequency spectrum

• With zero padding, the OFT can be used in linear filtering

16. How many multiplication and additions are required to compute N-point OFT using radix-2 OFT?

Solution

The total number of multiplications required to compute N-point OFT is N log2 N and the total number ofadditions is N log2 N. 2

Page 107: Dsp Matlab & Two Marks

TQA·64 • Digital Signal Processing

17. Draw the direct form realization of FIR system?Solution

The system function of an FIR filter can be written asN-I

H(Z) = L h(n)rnn=O

= h(O)+h(l)r1 + h(2)r2 + ... + h(N _l)r(N-I)

Y(Z) = h(O)X(Z)+ h(1)r1 X(Z)+ h(2)r2 X(Z)+ ...+ h(N _l)Z-(N-1) X(Z)

It can be realized as shown below.

)((n)

h(O) h(1) h(2) h(N-2) h(N - 1)

y(n)

18. Is the OFT ofa finite length sequence periodic?Solution Yes

19. What do you mean by in-place computation in FFT?Solution

In the butterfly structure the computations are done on the inputs x and y to produce complex outputs X andY. These outputs are stored in the same location of the inputs which limits the required memory to minimum.Since the output is placed in the input location itself the computation is also known as in-place computation.

20. Determine the 8-point OFT ofthe sequencex(n)= {0,0,1,1,1,0,0,0}.Solution

.( 21t)k-"N-l -.I IiX(k)= Lx(n)e k=O,I, ...,N-l

n=O

For k=O,

Fork=l,

{ )k-nN-I -.I ~= L x(n)e k = 0, I, ... , 7

n=O.7

x(O) = L x(n)eOn=O

=0+0+1+1+1+0+0+0=3

x(O) = ± x(n)e -( ~)n

= n:(oO)+ x(1)e- i( ~) + x(2)e - i( %) + x(3)e -f:).51t .31t .71t. -.1- -.1- -.1-

+x(4)e-.I1t +x(5)e 4 +x(6)e 2 +x(7)e 4

= -1.707 -1.707 j

Page 108: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·65

For k=2,

x(2) = ±x(n)e -j(%}n=O

.3rr-j-=x(2)e-jrr +x(3)e 2 +x(4)e-j2lr

=-1+)+1=)For k= 3,

x(3) = ±x(n)e-f:}n=O

.3rr .9rr-}- -j-= x(2)e . 2 + x(3)e 4 + x( 4)e -j3rr

=)+0.707-0.707)-1

=-0.293+0.293)Fork=4,

7

x(4) = L x(n)e-jrrnn=O

= x(2)e-j2rr +x(3)e-j3rr +x(4)e-j4rr

=1-1+1=1

For k= 5,7 .5rr-j-n

x(5) = L x(n)e 4

n=O

5rr .15rr-}-c- -j- .

=x(2)e· 2 +x(3)e 4 +x(4)e-j5rr

= - )+0.707+0.707)-1

= -0.293 - 0.293)Fork=6,

7 .3rr-j-nx(6) = L x(n)e 4

n=O

.9rr-j- .=x(2)e-j3rr +x(3)e 2 +x(4)e-j6rr

=-1- )+1=-)

Fork=7,7 .71r-}-n

x(7) = L x(n)e . 4n=O

7rr .21rr-j- -j- .=x(2)e 2 +x(3)e 4 +x(4)e-j71r

=)-0.707+0.707)-1

= -1.707 + 1.707)

x(k) = {3, -1.707 + 1.707), ), - 0.293 + 0.293), 1, -0.293 - 0.293), - ), -1.707 + 1.707)}

Page 109: Dsp Matlab & Two Marks

TQA·66 • Digital Signal Processing

21. Findy(n) if h(n) = {1, 1, I} and x(n) = {I, 2, 3, I} using circular convolution.

Solution

h(n) = {I, 1, 1, O}

x(n) = {I, 2, 3, I}

y(n) = x(n) * h(n)

x(1) = 2

x(2) = 3 x(O) = 1

2

x(3) = 1

y(O) = 1 + 0 + 3 + 1 = 5

2

1

y(1)=1+2+1=4

2

33

1

y(2) = 1 + 2 + 3 = 6 y(3) = 0 + 2 + 3 + 1 = 6

22. What is decimation-in-frequency algorithm? Explain the similarities and difference between DIT and DIFalgorithm.

Solution

In DIF algorithm the Fourier coefficient X(k) is decimated in diyadic fashion. In this algorithm the inputN

sequence x(n) is partitioned into two sequence, each of length 2 samples. The first sequence xl (n) consists

offirst ~ samples ofx(n) and the second sequence x2(n) consists of the least ~ samples ofx(n), that is,N

x,(n)=x(n), n=O,I,2""'2-1

N

n=O,I,2""'2-1

Page 110: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·67

If N = 8, the first sequence XI (n) has values for O:s; n S 3 and X2 (n) has values for 4:S; n:S; 7.The N-point OFT ofx(n) can be written as

N2-1 N-I

X(k) = L x(n)WNk + L x(n)WNkn=O Nn=-

2

!i_I !i_I N

2 2 (n+-)k= L x) (n)WNk + L x2(n)WN 2

n=O n=O

N N

2-1 nk2-1

= L XI (n)WNk +wi L x2(n)WNk_0 n~

!i_I !i_I2 2

= L XI (n)WNk +e-itrk L x2(n)WNkn=O n=O

when k is even e-itrk = I,

!i_I2

x(2k) = L [xI(n)+x2(n)]W~Kn=O

!i_I2

= L [xI(n)+x2(n)]WNKn=O 2

(1)

N NEquation (1) is the "2 -point OFT of the "2 -point sequence obtained by adding the first half and the last

half of the input sequence.

When k is odd e-i1rk = -I,!i-I2

X(2k+l) = L [xI(n)-x2(n)]W~2k+l)nn=O

!i-I2

= L [xI(n)-x2(n)]WN' WNkn=O 2

N NSimilarly the 4" and 8" -point OFT can be performed and the final structure can be obtained.Differences

(a) For decimation-in-time (DIT), the input is bit-reversed while the output is in naturai order. Whereas,for decimation-in-frequency the input is in natural order while the output is bit-reversed order.

(b) The DIF butterfly is slightly different from the DIT wherein DIF the complex multiplication takes placeafter the add-subtract operation. .

Page 111: Dsp Matlab & Two Marks

TQA·68 • Digital Signal Processing

22

Similarities

(a) Both algorithms require N log2 N operations to compute the DFT. Both algorithms can be done in

place and both need to perform bit-reversal at some place during the computation.

23. Perform circulator convolution on Xt (n) = {I, I, 2, I}; x2 (n) = {I, 2, 3, 4}.

1

1y(O) = 1 + 4 + 6 + 2 = 13

1

1y(1) = 2 + 1 + 8 + 3 = 14

2

1

y(2) = 3 + 2 + 2 + 4 = 11

2

1

y(3) = 4 + 3 + 4 + 1 = 12

24. Determine whether the following systems are LTI.

Solution

(i) y(n) = Ax(n) + B

Let XI (n), andx2(n) be two inputs

Yt(n) = AXt(n)+ B; Y2(n) = AX2(n)+ B

Let x3(n) = axl (n)+ bX2(n) , then

Y3(n) = AX3(n)+B

= A(axl(n)+bx2(n»+B

= aAxt(n)+bAx2(n)+ B:;tAYt(n)+ B

Therefore, the system is non-linear.

Page 112: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA-69

(i) Introduce a time delay inputx(n)

Yt(n) = Ax(n-K)+B

Introduce a time delay to entire response

y(n-k)= Ax(n-K)

Equate (1) and (2),

Therefore, the system is time invariant.

(ii) y(n) = x(2n)

Let xt(n), x2(n) be two inputs

Y3(n) =x3(2n)

= axt (2n) +bX2(2n)

= ayt(n)+bY2(n)

There the system is linear.

Introduce a time delay to inputx(n)

Yt (n) = x(2n- K)

Introduce time delay to entire response

y(n - K) - x(2n - K)

Equate (1) and (2)

Therefore, the system is time invariant.

25. Determine the 8-point DFT of x(n) = 1for -3 ~ n ~ 3 using DIT-FFT algorithm.

Solution

Let x(n) = {I, 1, 1+ 1, 1, 1, O}.

Let us shift x(n) by three steps left, that is,

x(n-11o) = q, 1, 1, 1, 1, 1, I, O}o

_/1rmkWeknows,DFTof[x«n-11o»N]=e N X(k)

_/1r(_3)k j321rk /1rk

Therefore, find the DFT of x(n-no). Similarly, the DFTcoefficients of e N = e 8 = e 4 .

xr(n) = {I, 1, 1, 1, 1, 1, 1, OJ.

(1)

(2)

Page 113: Dsp Matlab & Two Marks

-l0 > .:...C> • 0<C

- n; en<C

-:::

J~ -U0nX

(0)

<t>

enen :::J

X(1

)

<C

X(2

)X

(3)

X(4

)X

(5)

X(6

)X

(7)

-j 0.70

7-jO

.707

-0.

707

+jO

.707

4+3=

7

0.70

7+

jO.7

07

-07

07-

jO.7

07

2.

WN

=-J

oW

N=

1

3.

WN

=-0

.707

-JO

.707

2-2=

0

-j2+1=

3

2-1

=1

0-0=

0

2+2=

4

0+0=

0

-1W

~=

-12o

WN

=1

2

W~

=1

2oW

N=

12

2 o2 oo

x(0

)=

1

x(4

)=

1

W~

=1

x(2

)=

1

4

x(6

)=

1

W~

=1

-1

x(1

)=

1

4

x(5

)=

1

0W

'i=

1

-1

x(3

)=

1

4

x(7)

=0

0W

N=

1-1

4

Page 114: Dsp Matlab & Two Marks

=1(-1)=-1

Two Marks Questions and Answers • TQA·71

Now multiply the output ofFFT structure with the delay introduced while shifiting the zero reference to 3step let.

[ .3rr 0]

X(O) = e}4 ·7

= lx7 = 7 [ .3rr]

X(l) = [-0.707 - jO.707] e}4

=[-0.707- jO.707] [-0.996+ jO.088]

= 1.336 + jO.082

X(2) =-j [/:.2]3rr

}-= - je 2

= - j(0.984 - jO.176)

= -0.176 - jO.984

X(3) =(0.707- jO.707) (-0.924- jO.383)

= -0.923 + j0.383

13rr.4

X(4)=I'e 4

= l'e3rr}

}rr.sX(5) = 0.707 + jO.707.e 4

. [15n. . 15n]=(0.707+ jO.707) cos4+ jsm4= (0.707 + jO.707) (0.707 - jO.707)

= 0.499 - j0.499 + j0.499 + 0.499 = 0.998

}rr.6X(6) = je 4

[ 9rr]

}-= j e 2

[ 9n . 9n]= j cos2+ jsm2

=j[O+ j]=-1

Page 115: Dsp Matlab & Two Marks

TQA·72 • Digital Signal Processing

= [-0.707 + jO.707] [-0.707 + j(-0.707)]

= 0.499+ j0.499- j0.499 + 0.499 = 0.998

26. Find the 4-point DFT of x(n) = {O,1, 2, 3}

N-I _ i21!nk

X(k)= Lx(n)e· N k=O,I, ... ,N-In=O

Solution

(i) N=4,

3 _ j1!nk

:. X(k) = L x(n)e 2 k = 0, I, 2, 3n=O

k=O,

3

X(O) = Lx(n) eOn=O

= x(0)+x(1)+x(2)+x(3)

=0+1+2+3=6

k= 1,

3 j"n

XCI) = Lx(n) e--2n=O

= X(O)+x(1) (-j)+x(2) (-I)+x(3) (j)

=0+(1) (-j)+2(-I)+3(j)

= -2+2jk=2,

3

X(2) = L x(n) e-j"nn=O

= X(O)+x(1) e-j" +x(2)e-2j1! +x(3) e-3j1!

= 0+(1) (-1)+2(1)+3(-1) =-2k= 3,

3 3j1!n

X(3) = L x(n) e--2-n=O

3j1! _ 9j1!n

= x(O) + x(1) e-2 + x(2)e-3j1! + x(3) e 2

= 0+(1) (j) + (2)( -1)+ (3) (- j)

=-2-2j

:. X(k) = {6,-2+2j,-2,-2 -2j}

(ii) x(n) = {I,0,

0~n~5

otherwise

Page 116: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·73

DTFT,co

X(ejCO) = L x(n)e-jronn=......(XJ

5

= Lx(n)e-jconn=O

= eO+e-2jco +e-jco +e-3jco +e-4jco +e-SjCO

= 1+ e-jco + e-2jco + e-3jco + e-4jco + e-Sjco

27. Find the impulse response of the given difference equation

y(n- 2)- 3y(n -1)+ 2y(n) = x(n -I)Solution

Z-2Y(Z)-3Z-1y(Z)+ 2Y(Z) = Z-IX(Z)

Y(Z)[Z-2 -3Z-1 +2]= Z-IX(Z)

H(Z) = Y(Z)X(Z)

Z-l= 2 1 => system functionZ- -3Z- +2

(i) Perform convolution of x(n) = {I, 2, 3, 4, 5}; h(n) = {I, 2, 3, 3, 2, I}.

~ 12345h(n ,

, ,, ,",,

, ,, ,, ,1

12,3,,4,

5" ,, ,, ,,,,

, ,, ,,, ,,, ,,,, ,,, , ,, , ,,, ,,,, ,,

2 2,,4,,6,,8, 10,

, ,, ,, ,, ,,,, , ,, ,, ,, ,,,

, ,, ,,, ,,3

,,3 ,,6,,

9,,

12,15, ,, ,,, ,, , ,, ,,

,, ,, ,,, ,,

,, ,, ,, ,, ,,, ,,

3,3 ,,

6,9 ,,

12,,",

1~,, , ,, ,,,

, ,, ,,,,, , ,, ,, ,,,

, ,, ,, ,, ,,, ,,,,2 2,,

4,,6 ,,8,,

1q,, ,,,, ,, ,, ,, , ,,,, ,,, ,,, ,, , ,, ,, ,, ,,,

, ,, ,,, ,,1 1,,

2,,3,,

4,,5"

, ,, , ,,

:. y(n) = {I, 4, 10, 19, 30, 36,35, 26, 14, 5}

28. Find the Fourier transform of x(n) = (~ru(n).co

X(eJcon) = L x(nfe-jconn=-«>

.. (I)n= L - u(n)e-Jwnn=- 2

Page 117: Dsp Matlab & Two Marks

TQA·74 • Digital Signal Processing

I-!T129. Find the inverse Z-transform of X(Z) = I 3 I' IZI > 2(l-T ) (l+2T )

Z-}3Z

I+TI-2T2Z-I3Z Z(Z -I)=----=----

Z2+Z-2 3(Z2+Z-2)Z2

Z(Z -I) z= =---3(Z +2) (Z -1) 3(Z + 2)

X(Z) I'--=---Z 3(Z +2)

I:. x(n) =-( -2t u(n)

3

:. It is given IZI > 2.

(Inx n) = -(-2) u(n)3

30. Find the convolution of x(n) = {I, 2, 3, 4, 5,6}

y(n) = {2,-4, 6, -8}Solution

~h(n)

123456,

,, ,,,, , ,, ,,,, , ,,,

2 24,,6,8 19,'

,12, ,,,

, ,, ,, ,, , ,,, ,, ,, ,,,,,,."'-12

,,, ,-4,-4 ,-8 -1~/-29·',-24, , ,, , ,,, ,,, ,, ,, ,,,, ,, ,,,, , ,

6 612,18,,2~/ 30,, 36. ,, ,,, . ,,. . ,. ,, ,, ,,. ,,,,

-8,

-8 .':"'16.'-24 ,.-32

,-4q/ -48, ,.. , .,. ,. .,,

x( n) * y( n) = {2, 0, 4, 0, - 4, - 8, - 26, - 4, - 48}

Page 118: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·75

31. What is the need for FFT?Solution

N-I _j21rnK

The direct evaluation of OFT using the formula, X(K) = L x(n)e N , requires N2 complexn=O

multiplications and N(N -1) complex additions. Thus for reasonably large values of N (in the order of 1000)

direct evaluation of the OFT requires an large amount of computation. By using FFT algorithms, the number ofcomputation can be reduced. For example, for an N-point OFT, the number of complex multiplications required

N

using FFT is '2log2 N. If N = 16, the number of complex multiplications required for direct evaluation of OFTis 256, whereas using FFT only 32 mulitplications are needed.

32. Distinguish between OFT and DTFT.

S.No. DFT DTFT1.

Uses circular convolution Uses linear convolution

2.

Length of sequence is finite Length of sequence can be finite

3.

It has discrete frequency spectrumIt has continuous frequency spectrum4.

Implementable in digital computerCannot implemented in digital computer

33. Perform circular convolution of the given data sequences.

Solution xI (n) = {I, 2, 3, 4}; x2 (n) = {4, 3, 2, I}

X1 (1) = 2 2

x1(3) = 4

Y1 (n) = 4 + 2 + 6 + 12 = 24

2

3

4

Y2(n)=3+8+3+8=22

2

3

4Y3(n) = 2 + 6 + 12 + 4 = 24

3

4

Y4(n) = 1 + 4 + 9 + 16 = 30

...y(n) = {24, 22, 24, 30}

Page 119: Dsp Matlab & Two Marks

TQA·76 • Digital Signal Processing

35. Find the 10FT of X(k) = {5, 0, (1- j), 0, I, 0, (I + j), O}Solution

1 N-) .{211")nkx(n)=-:LX(k)e N ;k=O,I, ...,N-I

N k=O

1 9 . {':)nk=- :LX(k)e S ; k =0,1, ...,9

10 k=O

For n=O,1 9

x(O) = - :L X(k)eO10 k=O

1=-[5+0+1+ j+O+I+O+I+ j+O]10

8+2j 4+j=--=--10 5

Forn= I,1 9 }1I"k

x(l) = - :L X(k)e S

10 k=O

I[ }11" }211" 1311" . 1711" 1811"]=}O 5eO+0.eS +1·e S +je S +0+leJ1I"+0+e S +je S

= -..!..-[5 + 0 + 0.309 + 0.95 j - 0.309 - 0.95 -1- 0.369 - 0.95 + 0.309 j + 0.95]10

2=-5

For n=2,

1 9 1211"k

x(2)=- :LX(k)e S

10 k=O

1 [ j411" j611" . 11411" j1611"]=}O 5eO+0+I·e S +je S +0+leJ211"+0+e S +je S

= -"!"-[5+0-0.809+0.588j -0.809+0.588+ 1-0.809+0.588j -0.809j +0.588]10

= -..!..-(5.558- 0.442j) = 0.558-0.0442j10

Page 120: Dsp Matlab & Two Marks

Forn=3,

For n =4,

Forn=5,

Forn=6,

Two Marks Questions and Answers • TQA·77

1 9 j3nk

x(3)=- IX(k)e S

10 k=O

1 [ j6n j9n . j21n j24n]=10 5eo+0+e S +je S +0+eJ3n+0+e S +je S

= -"!"-[5-0.809-0.588j+0.809j +0.588-1+0.809+0.588j -0.809j -0.588]10

2=-5

1 9 j4nk

x(4)=- IX(k)e S

10 k=O

1 [ j8n j12n . j28n j32n]=105eO+l.eS +jeS +eJ4n+es +jeS

1

= 10[5 + 0.309 - 0.95 j + 0.309 j - 0.95 + 1+ 0.309 - 0.95 j + 0.309 j - 0.95]

= -"!"-[4.718-1.282j]10

= 0.4718-0.1282j.

x(5) = -..!..- ±X(k)ejtrk10 k=O

= 1~[5eO +1.ei2n + jej3n +eiSn +ei7n + jej8n]

=-"!"-[5+1- j-l-l+ j]10

2=-5

1 9 j6n k

x(6) = - I X(k)e S10 k=O

1 [ .6n .1811' .427r .48n]= 10 5eO+ eJS + jeJs + ej67r + /-s + jeJ-s

1= -[5 + 0.309+ 0.95j + 0.309 j + 0.95+ 1+ 0.309+0.95j +0.309 j + 0.95]

10

= -"!"-[8.518+ 2.518j]10

= 0.8518+0.2518j

Page 121: Dsp Matlab & Two Marks

TQA-78 • Digital Signal Processing

Forn =7,

1 9 /"kx(7) :;:;- L X(k)e 5

10 k=O

1 [ J 14" J~ . /9" /6" ]=10 5eO+1.e 5 +je 5 +e/7"+e 5 +je 5

1= -[5 -0.809+ 0.588j +0.809 j -0.588-1 +0.809-'- 0.588j -0.809j + 0.588]10

2=5

Forn=8,

1 9 }"kx(8)=- LX(k)e 5

10 k=O

1 [. .116" /4" . /6" 172"]= 10 5eo+ e 5 + je 5 + e/8" + e 5 + je 5

1= -[5- 0.809- 0.588j - 0.809j -0.588+ 1-0.809-0.588j -0.809j - 0.588]10

1= -[3.206-2.794j]10

= 0.3206-0.2794j

For n= 9,

• 1 9 /" k

x(9)=- LX(k)e 5

10 k=O

1 [ .18" .27" .63" .81"]=10 5eO +e/5 + je/-5 +ej9" +e/-5 + je/5

1

= -[5+ 0.309-0.95j -0.309j + 0.95 -1-0.309+0.95j + 0.309j -0.95]10

2=5

x(n) = [0.8+ O.2j, ~, 0.56 -0.04j, ~, 0.47 -O.13j, ~, 0.85+0.25j, ~, 0.32 -0.28j,~]55555

Page 122: Dsp Matlab & Two Marks

Chapter 6 Z-Transform

l-.!.rlI. Find the inverse Z-transform of X (z) = 1 3 1 ' IZI > 2(l-r )(1+2r )Solution

l-.!.rlX(Z) = 3

(l-rl) (1+2r1)

X(Z)=_A_+ B1-r1 1+2r1

A =(l-rl) X(Z)I Z-I=I

1-.!.r1A= 3

1+2Z-11

1-3 2=-=-1+2 9

B = (1+2r1) X(Z)Iz-'=_o.5

1-.!.r1B= 31-r1

I1+"6 7

= 1+!- ="92

2 7- -X(Z)=_9_+ 9

l-r1 1+2rl2 7 n

x(n) = -u(n)+-(-2)9 9

Page 123: Dsp Matlab & Two Marks

TQA·80 • Digital Signal Processing

2. Find the inverse Z-transform of X (Z) = 1 . For ROC 0.5 < Z > 1 .I-UTI +0.9T2Solution

X(Z) = 1(l-TI) (l-0.5TI)

A B=--+---I-T1 1-0.5T1

A = (l-TI)X(Z)lrl=1

=_1_=21-0.5

B = (l-0.5T1)X(Z)lrl=2

=_1_=_11-2

2 -1

X(Z) = I-TI +1-0.5rlx[n] = 2u[n]-(O.5tu[n]

3. Find the impulse response of the stable system whose input-output relation is given by the equation.

y[n] -4y[n-l] +3y[n- 2] = x[n]+ 2x[n -I]

3

_2_I-T1

Solution

y[n] - 4y[n -I] + 3y[n - 2]= x[n] + 2x[n-I]Y(Z)-4T'Y(ZJ+3r2y(Z) = X(Z)+2TIX[Z]

Y(Z) [1-4T1 +3T2] = X(Z) [1+2rl]

Y(Z) = H(Z) = 1+ 2TIX(Z) (l-3T1) (l-rl)

A BH(Z)=--+-­

1-32-1 I-TI

A=(l-3rl)X(z)I_'_1 z -31

1+2x- 5= __ -=-3 =_I_~ 2

3

B=(l-T1) X(Z)lrl=11+2 3=-:=--1-3 2

5

H(Z)= 2 I1-3T

Page 124: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·81

The impulse response of the stable system is given by

h(n) = ~(3r u(n) _iu(n)3 2

4. Find the overall impulse response of the system shown below.Y1(n)

x(n)

Solution

x(n)

II II ~

hI(n) = anu(n) * u(n -I)

Let us consider Z-transform of anu(n)~

Z[anu(n)] = I. anZnn=O

1=---1- aZ-1

y(n)

y(n)

00

Z[u(n-l)]= LZ-nn=1

Z-I= l-rl

The convolution in time domain is product in transform domain and vice versa. Therefore,

r1HI (Z) = -----­

(l-ar1) (l-rl)A B---+--

l-arl l-rl

A = (l-arl) HI (Z)lrl=~a

Page 125: Dsp Matlab & Two Marks

y(n)

TQA·82 • Digital Signal Processing

1

A= ~ =_1_1 a-II--a

B = (1-r1) HI (Zt-I=1

B=_I_I-a

-1 1- -H (Z)= I-a +~I l-aZ-1 l-Z-1

The inverse Z-transform

!Ij (n) = _I_{_(_at u(n)+ u(n)}1- a

0.(n) = c5(n- 2) * anu(n)

Zr[8(n-2)] = r2

zr[anu(n)] = 1 -1l-aZ

r2H2(Z) = 2l-ar

, 1 1H2(Z)=-+---a a(1-aZ-I)

0.(n) = .!.8(n) +.!. anu(n)a a

h(n) =!Ij (n) + h2(n)

h(n) = _1_{_( _a)n u(n) + u(n)} +.!.{8(n) + anu(n)}(1- a) a

5. Write the difference equation and the transfer function of the system in figure.b2

Take inverse Z-transform

y(n) - a1Y(n -1) - a2Y(n - 2) = ~x(n - 2)

Page 126: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·83

6. Determine the system function of the DT system described by the difference equation

1 1

(i) y(n) -"2 y(n -I) + 4"y(n - 2)= x(n) -x(n -I)Solution Take Z-transform

y(z)-~rly(z)+~r2y(Z) = X(Z)-X(Z)r12 4

Y(Z)[I-~rl +~r2 ] = X(Z)[I-r1 ]

(l-r1)H(Z)=-----[I_~rl+~r2]

H(Z)- l-r1[1- (0.25+ j0.433)r1 ] [1- (0.25 - j0.433)rl ]

(ii) What are the properties of ROC?

Solution Properties of ROC

(i) The ROC of X(Z) consists of a circle in the z-plane centered about the origin.

(ii) The ROC of X(Z) does not contain any poles.

(iii) Ifx(n) is of finite duration, then

(a) ROC is the entire Z-plane except at Z = 0 for right handed sequence.

(b) ROC is the entire Z-plane except at Z = 00 for left handed sequence.

(c) ROC is the entice Z-plane except atZ= 0, Z = 00 for two sided sequence.

(iv) If x(n) is a right sided sequence and if the circle IZI = Yo is in the ROC, then all finite values of Z for

IZI > Yo will also be in the ROC.

(v) Ifx(n) is a left sided sequence and if the circle IZI = Yo is in the ROC then all values of Z for which

0< IZI < Yo will also be in the ROC.

(vi) Ifx(n) is a two sided sequence and ifthe circle IZI = Yo is the ROC, then the ROC will consist ofa circle

in the Z-plane that includes the cirlce IZI = Yo

(vii) If the Z-transform X(Z) of x(n) is rational then its ROC is bounded by poles or extends to 00.

(viii) If the Z-transform ofx(n) is rational and ifx(n) is right sided, then the ROC is the region in the Z-planeoutside the outermost pole.

(ix) Ifthe Z-transform ofx(n) is rational and ifx(n) is left sided, then the ROC is the region in the Z-planeinside the innermost pole.

7. What are the different methods of evaluating inverse Z-transform?

Solution Inert are four methods that are often used for the evaluation of the inverse Z-transform. They are

• Long division method

• Partial fraction expansion method• Residue method

• Convolution method

Page 127: Dsp Matlab & Two Marks

TQA·84 • Digital Signal Processing

8. Determine the impulse response of the following causal system y(n) - 2 cos (}y(n -I) + y(n - 2) = x(n).

Solution y(n) - 2cos(}y(n -1) + y(n - 2) = x(n)

Taking Z-transform

Y(Z) - 2 cos BY(Z)rl + Y(Z)r2 = X(Z)

Y(Z) (l-2cosBrl +r2)=X(Z)

Y(Z) = H(Z) 1X(Z) 1-2cosBrl +r2

9. Determine the Z-transform of the following

(i) x(n) = n(-It u(n)

Taking Z-transform<Xl

X(Z) = L x(n)rl1n=-r;t'J

n=-r:t')

d= -Z-X(Z) (by property)

dZ

=-Z ~(z~J= -Z (Z +I)-Z

(Z + 1)2

X(Z)= -Z(Z + 1)2

(ii) x(n) = (_1)11 cos( n;) u(n)

[ ] l-rZ-lcos(}We know that, Z rl1 cos n(}u(n) = 1 2 21-2rr cos(}+r r1r

Here r = -I' () = -, 3

Z[(-1)11 cos(mr)u(n)] ~ 1+ r1c(s~J3 1 2Z-1 1'C Z-2+ cos - +

3

1+!r1X(Z) = 2

I+Z-I+Z-2

Page 128: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·85

10. (a) y(n) = 0.7y(n-I)-0.ly(n-2)+2x(n)-x(n-2).

Solution x(n) = u(n)

Taking Z-transform on both sides,

Y(Z) = 0.7 [ Z-l Y(Z) + y(-I) ] - 0.1[Z-2 Y(Z) + Z-l y( -I) + y(l) ]

+2X(Z)- Z-2 X(Z) + Z-lx(-I)+x(-2)

Y(Z) = 0.7(Z-IY(Z»- 0.1(Z-2y(Z»+ 2X(Z)- Z-2 X(Z)

Z

X(Z) = Z-I

... Y(Z)-0.7Z-IY(Z)+0.1Z-2y(Z) = 2Z _ 2Z-2(Z)Z-I Z-I

Y(Z) [0.1Z-2 -0.7Z-1 +IJ=~- 2Z-1Z-I Z-I

Y(Z) (0.1Z-2 -0.7Z-1 +1)= 2Z-2Z-1(Z -I) (0.1Z-2 - 0.7Z-1 + I)

2(Z2 -I) Z-l=Z-2(Z-I) (0.I-O.7Z+Z2)

2(Z -I) (Z+ I) Z=(Z-I) (0.1-0.7Z+Z2)

. Y(Z) 2(Z + I)

.. Z (Z2_0.7Z+0.1)

Y(Z) 2(Z + I) = A + BZ (Z - 0.5) (Z - 0.2) (Z - 0.5) (Z - 0.2)

A =(Z _0.5)[Y(Z)]1Z 2=0.5

A = 10

B = (Z - 0.2)[ Y(Z)]IZ 2=02

B=-8

. Y(Z) 10 8--=-----Z Z -0.5 Z -0.2

... Y(Z)=~-~Z -0.5 Z -0.2

y(n) = 10(0.5)nu(n)-8(0.2)nu(n)

Page 129: Dsp Matlab & Two Marks

TQA·86 • Digital Signal Processing

j I, n ~ 0II. x(n) :::

3n, n < 0Solution

00

X(Z)::: L x(n)rnn=---<X:J

-I 00

::: L x(n)rn + Lx(n)rnn=-oo n=O

-I 00

::: L 3n rn + Lrnn=-oo n=O

00 00

:::L(r1zt + Lrnn=O n=O

00 00

:::1- L(3-1 zt + Lrnn=O n=O

I I:::1----+--l-r1z l-r1

l-r1Z-1 I----+--l-r1Z l-r1r'z Z---+--

r1Z-1 Z-IZ Z:::--+--

Z-3 'Z-II I

12. yen)-2" y(n-I)+ 4"yen- 2):::x(n)- x(n-I). Find the system function.I I

Solution y(n)-- y(n -I) + - y(n - 2) :::x(n)- x(n-1)2 4

Take Z-transform on both sides

1m

3 Re

y(z)-~rlY(z)+~r2y(z)::: X(Z)-r1X(Z)2 4

Y(Z>[I-~rl+±r2 ]::: X(Z)[I-r1 ]

:. H(Z)::: Y(Z)X(Z)

l-r1:::

1-!r1+!r22 4

l-r1:::

1-o.sr1 +0.2Sr2l-r1

= 1 1 ::::> System functionI--Z-1 +_Z-22 4

Page 130: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·87

13. Find Z-transform and plot its ROC.

Solution (i) x(n)={Sn _2n} u(n)00

X(Z) = L x(n)rn

1m00

= L [Sn-2nJu(n)rnn=-<XJ

= I,[sn -2nJrnn=O

00 00

= L(Srl)n - L(2r1tn=O n=O

I I=I-Sri 1-2rJZ Z=-----

Z-S Z-2

Re

ROC: Z > Sand Z > 2

ROC should not enclose any pole. Therefore, Z > S is considered forROC.

(ii) x(n) = cosn() u(n)00

X(Z) = L x(n)rnn=-oo

00

= L cosneu(n)Z~nn=-oo

ROC :IZI > I

1m

Re

Page 131: Dsp Matlab & Two Marks

TQA·88 • Digital Signal Processing

(iii) x(n) = {I, 0, 3, -1, 2}. Find the Z-transform.tSolution

X(Z) = 1+ 0 + 3Z-2 -1Z-3 + 2Z-4

14. What is the relationship between OFT and Z-transforms?

Solution Let us consider a sequence x(n) of finite duration Nwith the Z-transformN-I

X(Z) = Lx(n)Z-nn=O

The OFT is given by,N-l 2trkn

X(k) = L x(n)e-rNn=O

Compare equation 1 and 2

X(k) = X(Z)lz=e-j21r kN

15. (a) Find the output response of the given system

y(n) - 3y(n-l) -4y(n - 2) = x(n) + 2x(n -1); x(n) = 4nu(n)

Solution Taking Z-transform

Y(Z)-3Z-1Y(Z)-4Z-2y(Z) = X(Z) +2X(Z)'Z-1

Y(Z)[1-3Z-1-4Z-2J=X(Z) (l+2Z-1)

Zx(n) =4nu(n) => X(Z) =-­Z-4

Substitute equation (2) in (1)

Y(Z)(Z2 -3Z -4)=~ (Z+2)Z2 Z-4 Z

Y(Z)- Z2(Z+2)(Z - 4) (Z - 4) (Z + 1)

Y(Z) Z(Z+2)

Z= (Z-4i (Z+I)

__ Z_(Z_+_2_)_= _A_ + B +_C_(Z _4)2 (Z +1) Z -4 (Z _4)2 Z +1

Z(Z +2) = A(Z -4) (Z + 1)+ B(Z + 1)+C(Z _4)2

Put Z = 4,

24=5B

5B=­24

(1)

(2)

(1)

(2)

Page 132: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·89

PutZ=-I,

-1= 25C

1C=-­25

Comparing Z2 termsI=A+C

A = 2625

Y(Z) 26 5 1..-- =---+--------Z 25(Z - 4) 24(Z _ 4)2 25(Z + 1)

Y(Z)= 26Z + 5Z Z25(Z - 4) 24(Z - 4)2 25(Z + 1)

26 ( )n 5 ()n 1 ( )ny(n)=- 4 u(n)+-n 4 u(n)-- -1 u(n)25 24 25

(b) Region of convergence

The region of convergence of X(Z) is the set of all values of Z for which X(Z) attains a finite value.

Properties of ROC

(i) The ROC is a ring or disk in the z-plane centered at the origin.

(ii) The ROC cannot contain any poles.

(iii) The ROC of an LTl stable system contains the unit circle.

(iv) The ROC must be a connected region.

(c) Relationship between ZT and FT

We know that the Z-transform of h(n) is given by00

H(Z) = L h(n) rnn=-oo

where,

Substitute equation (2) in (l)00

H(rej(J)) = L h(n) (rej(J)rnn=-oo

The Fourier transform of h(n) is given by~

H(eJW) = L h(n) e-jwnn=-oo

(1)

(2)

(3)

(4)

Equations (3) and (4) are identical when r = 1. In the z-plane this corresponds to the locus of points on the

unit circle IzJ = 1. Hence H(ejW) is equal to H(Z) evaluate along the unit circle, or

H(ej(J)) = H(Z)lz=eJ'"

Page 133: Dsp Matlab & Two Marks

TQA·90 • Digital Signal Processing

. 1+3Z-116. Fmd the Z-transform of X(Z) = 1 2 for IZI> 2.I+3Z- +2Z-Solution

X(Z) = (Z +3)Z(Z2 +3Z +2)

X(Z) Z+3

----z- = Z2 +3Z +2

X(Z) Z+3 A B--=----=--+--Z (Z + 2)(Z + I) Z + 2 Z + 1

Z +3 = A(Z +I)+B(Z +2)PutZ = -1,

2=BPutZ = -2,

A=-I

X(Z) -1 2--=--+--Z Z+2 Z+I

-Z 2ZX(Z)=--+-

Z+2 Z+ITaking inverseZ-transform,

x(n) = -(-2tu(n)+ 2(-Itu(n)

17. What is the response of the LSI system with impulse response h(n) = 8(n)+ 28(n-I) for the input

x(n) = {I, 2, 3}?

Solution

h(n) = 8(n)+ 28(n-I) = {I,2}The Z-transform of h(n) is,

H(Z) = Y(Z) =(1+2Z-1)X(Z)

Y(Z) = (1 + 2Z-1)X(Z)

x(n) = {I, 2, 3}

X(Z) = I+2r1 +3Z-2

Substitute equation (2) in (I),

Y(Z)= (1+ 2r1) (1+ 2r1 + 3r2)

= 1+ 2Z-1 + 3Z-2 + 2Z-1 + 4Z-2 + 6Z-3

= I+4Z-1 +7Z-2 +6Z-3

The output response of the LSI transform is

y(n) = 8(n) + 48(n -I) + 78(n - 2) + 68(n -3)

(1)

(2)

Page 134: Dsp Matlab & Two Marks

Chapter 7 Finite Impulse Response Filter

1. Explain in detail about frequency sampling method of designing an FIR filter.Solution

This method is one of the methods of designing an FIR filter. In this technique a set of samples is determinedfrom a desired frequency response and these samples are identified as DFT coefficients. The signals can befound by taking 10FT of those samples.

Let the desired frequency response be

N-l -Jell')nkHd(eiaJ) = Lhd(n)e N , k=O,I, ... ,N-I

n=O

Let the frequency samples be choosen at2n

wK = /ik where k = 0, I, 2, ... ,N-I

:. Sampled frequency response H(k) is related to the desired frequency response Hd(eJaJ) as

H(k) = Hd(eJaJ)i", __2/r'k~ k=O,I, ...,N-1N

Let H(k) = IH(k)I'eJB(k), where 6(k) = -awlw=21l'.k .. N

For a hnear phase filter.

N-ISince a=-­

2

[N-I]2n6(k) = - -2- '/ik

(N-I)6(k)=- 7 d, wherek=O,I, ... ,N-l

Since O(k) is a odd function it satisfies the condition O(k) = -O(N - k)

:. From equation (1), becomes

[N-I] [N-I]-7 d= 7 n(N-k) where k=O, 1,...,N-I

(I)

For odd values of N

{ [N-I]

-7 d,O(k) =

(N ;1)n(N -k), N-I }

k =0,1'''''-2-N+l

k=-2-, ..·,N-I

Page 135: Dsp Matlab & Two Marks

TQA·92 • Digital Signal Processing

For even values of N

{ [N -I]

-N d,8(k) =

(N; 1}r(N _ k),

h(n) can be obtained by taking lDFT of H(k).

If the tilter coefficient are linear and symmetric then the below condition is satisfied.

h(n) = h(N -1- n)

Since h(n) should be real we get.

For odd N,

For even N,

Once h(n) is calculated the frequency response H(ejW) can be found based of whether N is odd or even.

2. Explain the steps involved in the design of FIR tilter using window method.

Solution

(a) Given the desired frequency response Hd(ejW) find the desired impulse response hd(n) using the

I rr . .

formula hd(n)=- J Hd(eIW).eIWn dO).2n -rr

This impulse response will have n values ranging between -00 to +00.

N-I(b) Hence determine h(n) for Inl:::; -2-' where N is the length.

(c) Based on the window technique choose the window function w(n) and find its window coefficient for

Inl:::; N-I.2

N-I(d) Find h(n) = hd(n)w(n) for Inl:::; -2-'(e) Calculate the tilter transfer function

N-l2

H(Z) = h(O)+ Lh(n)[2n+Tn]n=l

Substitute h(n) found from previous step.

Page 136: Dsp Matlab & Two Marks

N-lInl~­2

Otherwise

Two Marks Questions and Answers • TQA·93

(N-t)(t) To design a causal filter multiply H(Z) by ·Z1. 2

:. H(Z) = H(Z) Z-( N2-1)

(g) The frequency response H (ejaJ) equation is taken based on whether N is odd or even and frequency

response is symmetric or asymmetric. The h(n) values in H(eJaJ) is found from HZ equation and

the FIR filter is designed.

3. What are the desirable characteristics of the window?

Solution The desirable characteristics of the window are

• The central lobe of the frequency response of the window should contain most of the energy andshould be narrow.

• The highest side lobe level of the frequency response should be small.

• The side lobes of the frequency response should decrease in energy rapidly as OJ tends to If.

4. Give the equation specifying Bartlett and Hamming windows.

Solution

• The N-point Bartlett window is given by

jl- 2(n)

wB(n) = N-l'0,

• The equation for Hamming window is given by

10.54+0.46cos( 27T:n), Inl ~ N -1wH(n) = N-l 2

0, Otherwise

5. What is the condition for linear phase ofa digital filter?

Solution The conditions for linear phase ofa digital filter are

(a) phase delay must be constant

(b) differential of phase delay, that is, group delay must be constant

where B(OJ) is the phase response

OJ is the angular frequency

a is a constant phase delay.

6. Give the transfer function of Hanning & Hamming Window function.Solution

(a) The transfer function of Hamming window is

10.54+0.46cos( 27T:n), Inl~N-lwnm (n) = N -1 2

0, elsewhere

(b) The transfer function of Hanning window is

10.5+0.5cos( 27T:n), Inl ~ N -1

Wnn(n)= N-l 20, elsewhere

Page 137: Dsp Matlab & Two Marks

TQA·94 • Digital Signal Processing

7. What are the advantages and disadvantages of FIR filter?Solution

Advantages of FIR Filters

(a) FIR filters are always stable.

(b) FIR filters with exactly linear phase can easily be designed.

(c) FIR filters can be realized in both recursive and non-recursive structures.

(d) FIR filters are free oflimit cycle oscillations when implemented on a finite word length digital system.

(e) Excellent design methods are available for various kinds of FIR filters.

Disadvantages of FIR Filters

(a) The implementation of narrow transition band FIR filters are very costly, as it requires considerably morearithmetic operations and hardware components such as multipliers, adders and delay elements.

(b) Memory requirement and execution time are very high.

8. Determine the desired impulse response ofFIR-LPF whose delayed desired frequency response is

Hd(eJW)= je-JIlW, Iwl::;%0, OtherwiseSolution

1 ~ .

H (n) = -f 3 e-JWJJ eJwn dO)d 2n -1!3 '

1!

= -I-f) ej(n-u)w dO)2 -1!n­3

1!

= _1 [eJ(n-U)W ])2n j(n-a) -1!3

= 1 r ej(n-U)~ - e- j(n-u)~ 1n(n-a)l 2j

ForHPF,

For BPF,

For BSF,

sin(n -a)~hd(n) = 3

n(n -a)

sin(n -a)n - sin(n -a )~hd(n) = 3

(n-a)n

. ( ) 2n . ( ) nSinn-a --Sin n-a -hd(n) = 3 3

n(n-a)

sin(n -a)n - sin(n -a)~ -sin(n -a) 2nhd(n) = . 3 3

n(n-a)

Page 138: Dsp Matlab & Two Marks

Chapter 8 Infinite Impulse Response filter

1. Obtain the cascade and parallel form realization for the following system.

y(n) = -O.ly(n -I) + O.2y(n- 2)+ 3x(n)+ 3.6x(n-1)+ 0.6x(n- 2).

Solution y(n) = -O.ly(n -1)+ O.2y(n- 2)+ 3x(n)+ 3.6x(n-I)+ 0.6x(n- 2)Take Z-transform

Y(Z)+0.lrIY(Z)-0.2r2y(Z) = 3X(Z)+3.6rIX(Z)+0.6Z-2 X(Z)

Y(Z)[1+0.12-1-0.2r2J = X(Z)[3+3.6Z-1 +0.6Z-2J

H(Z) = Y(Z)X(Z)

3+3.6rJ +0.6r2=------1+0.lr1 -0.2r2

1+ 1.2rl + 0.2r2=I+O.IZ-I -0.2r2

For cascade structure

H(Z) = H1(Z)·H2(Z)

= [: :~:~:~: ]t~+O~:;~I]W'1"1 '--'

Z-l

0.2 0.1

For parallel structure

'm---,y(n)1 -0.2

H(Z) = 1+ 1.2rl + 0.2Z-21+0.lrl-0.2Z-2

(l+rl) (l+O.2rl)=(l-O.lrl) (l+0.2rl)I+rl=

I-O.lrl

Page 139: Dsp Matlab & Two Marks

TQA·96 • Digital Signal Processing

Since the power of Nr = Dr' Use long division method to reduce the power of the Nr.-10

-0.1 Z-1 +1) Z-' + 1Z-1 + 10

11

11

H(Z)=-IO+ 1-0.1Z-1

Realizing the above expression as a structure

-10

--.x(n)

yen)

+ 0.1

2. Realize the following II order system using direct I form of realization.

yen) = yen -I) - 0.5yen - 3) + 0.5x(n -I)

Solution y(n)- y(n-I)+0.5y(n-3) = 0.5x(n-l)

x(n)

Z-10.5

yen)

3.4 3 2

An FIR filter is given by yen) = 2x(n) +- x(n -I) +- x(n - 2) +- x(n - 3). Find the lattice structure5 2 3

coefficient.

Solution Let us first draw the lattice structure for a III order equation.

fo(n) f1(n) f2(n)+

x(n)

Page 140: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·97

!J (n) = !o(n) + K1gO(n-I)=x(n)+K1x(n-l)

g, (n) = gO(n -1)+ Kdo(n)

= x(n -1) + K1x(n)

!2 (n) = !J (n) + K2g] (n -I)

= x(n) + K1x(n -I) + K2 [KJx(n -I) + x(n - 2)]

= x(n) + K1x(n -I) + K1K2x(n -1) + K2x(n - 2)

= x(n) + K1x(n -I) [I+ K2]+ K2x(n - 2)

g2 (n) = K2!J (n) + gl (n -I)

= K2 [x(n)+K1x(n-I)+K)x(n-I)+x(n-2)]

= K2x(n)+ KjK2x(n-I)+x(n- 2)+ K1x(n-l)

= K2x(n)+K1x(n-1) [1+K2]+x(n-2)

y(n) = !3(n)

=!2(n)+K3g2(n-l)

= x(n)+ K1x(n-I)[I+ K2]+ K2x(n-2)+

K3[K2X'(n -I) + K1x(n - 2)(1+ K2) + x(n - 3)]

= x(n) + K,x(n -I) + K,K2x(n -I) + K2x(n - 2)+ K2K3x(n-1)

+K1K3x(n - 2)+ K1K2K3x(n-2)+ K3x(n-3)

= x(n)+x(n-I) [K] + K1K2 + K2K3]

+x(n-2) [K2 + K1K3 + K1K2K3]+K3x(n-3)

General equation of FIR filter ofIlI order is3

y(n) = x(n)+ L am(K)x(n-k)K=l

=x(n)+a3(1) x(n-I)+a3(2) x(n-2)+a3(3) x(n-3)

Comparing (1) and (2)

a3(O) = 1

a3(1) = K, + K1K2 +K2K3

=K1[I+K2]+K2K3

(1)

(2)

Page 141: Dsp Matlab & Two Marks

TQA·98 • Digital Signal Processing

K2 =u2(2); K\(1+K2}=U2(1)

K1 = u2(1)l+u2(2)

:. U3(1) = U2(1) + U2(2)K3

General equation

um_I(O) = I, um(m) = Km

um_1 (K) = um(K) -Um(~)·Um(m - K) [I:::;K:::; m -I]I-um(m)

From equation (I),

K3 = u3(3)

:. u3(1) = u2(1)+u2(2)'u3(3)

Comparing the coefficient of x(n - 2)

u3 (2) = K2 + K]K3[K2 + I]

= K2 +K3{K](1+K2)}

= u2 (2) + u3 (3)'u2 (1)

Consider the equation4 3 2

y(n) = 2x(n) + -x(n -I) + -x(n - 2) + -x(n - 3)5 2 3

[ 2 3 1 ]=2 x(n)+-x(n-I)+-x(n-2)+-x(n-3)

5 4 3

=Ko[l+ ~Um(K)X(n-K)]

= Ko[l+u3(l)x(n-1)+u3(2)x(n-2)+u3(3) x(n-3)]

Comparing (I) and (2)

2

a) (1) = 5

3

a2(2)="4

1u3(3) =- = K3

. 3 -

Using General equations

U (K)=Um(K)-um(m)um(m-K) I:::;K:::;m-1m-] I-u;,(m)

Here m = 3,

u2(K)= u3(K)-u3(3) u3(3-K)l-u~(3)

(1)

(2)

Page 142: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·99

To find a 2(1), letK= 1

a2(1) = a3(1)-a3(3) a3(2)l-a;(3) .

2 I 3 2 1---.-_534_54

- I-Gr - I-i=0.16875

To find a2(2) , let K= 2

a2 (2) = a3 (2) - a3 (3) a3 (1)l-a;(3)

312-_-0-4 3 5=---I-or

= 0.69375

a2 (2) = K2 = 0.69375

K _ a2(1)1 - l+a2(2)

0.16875=1.69375

= 0.0996

Thus the lattice structure coefficients are

K1 =0.0996

K2 =0.69375

1

K3 =3'=0.333

4. Differentiate between recursive and non-recursive difference equation.

Solution In recursive difference equation, output depends on past input and output.N N

Eg. y(n) = - ~aky(n-k)+ ~bkx(n-k)k=l k=l

In non-recursive difference equation, output depends on past input only.M

y(n) = Lbkx(n - k)k=O

Page 143: Dsp Matlab & Two Marks

TQA·100 • Digital Signal Processing

5. Draw the direct from I structure for the system y(n) = O.5x(n)+ O.9y(n - I).Solution

0.5

'9x(n) $

•y(n)

0.9

y(n -1)

6. Mention the advantages and disadvantages of IIR filter.

Solution

Advantages ofIIR filter

(a) Requires fewer coefficients than an FIR filter for the same set of specifications.

(b) It is a better choice for filter having narrow transition band.(c) It is a recursive filter.

Disadvantages ofIIR filter

(a) Lack of stability.

(b) The IIR filter degrades the filtered signal if proper care is not taken in the design.

7. What are the advantages of lattice filter?

(a) Used extensively in digital speech processing and in implementation of adaptive filters.

(b) The coefficient K1, K2 etc are known as reflection coefficient.

(c) In case offorward predictor the production value ofx(n) is obtained by a weighted linear combinationof the past values ofx(n).

p

x(n)=-Lam(K)x(n-K) (I)K=I

ex (k) - forward prediction coefficientp

Forward prediction error Ip= x(n) - £(n) i.e. the difference betweenx(n) and predicted value ofx(n).p

i.e. Ip(n) = x(n) + Lan (K) x(n - K)K=I

(d) Backward Linear Prediction

In a sequence x(n), x(n -I), ...,x(n - P + I) ofx(n - P) has to be predicted we use a one step backward

linear pred iction where it is determined from the coefficient bp (K)P-l

x(n-m)=- L f3m(K) x(n-K) (2)K=O

Backward prediction error gp (n) is the difference between x(n - P) and £(n - P).

Note In case of lattice filter structure the coefficient of Y2 (n), g2 (n) are in reverse order

Y2(n) = 12(n)

= x(n)+ Kj (I+ K2)x(n-I)+ K2x(n- 2)

= x(n) + a2 (I) x(n-I)+a2(2) x(n-2)

Page 144: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·101

g2(n) = a2(2)x(n)+ a2(l) x(n-I)+x(n- 2)

.. Coefficient off2(n) = {I, a2(l), a2(2)}

g2(n) = {a2(2), a2(2)}In general,

m

fm(n) = ~am(k)x(n-K),am(O)=IK=O

m

gm(n) = ~ f3m(k) x(n-K)K=O

From equation (2) it is clear that to find x(n - m), the datas have to be run in the reverse order through the

predictor. Hence it is known as backward prediction. Whereas equation (l) is forward prediction.

8. Explain the various forms of realization ofIIR system?

Solution

(a) Direct form I structure(b) Direct form II structure(c) Transposed direct form II structure(d) Cascade form structure(e) Parallel form structure(t) Lattice-ladder structure

9. What are the advantages of direct form II and cascade structures.

Solution

(a) In direct form II realization, the number of memory elements required is less than that of direct form Irealization.

(b) Quantization errors can be minimized if we realize an LTI system in cascade form.

10. List the two important transformations to digitize on analog filter.

Solution

(a) Impulse invariance method

(b) Bilinear transformation method.

ii. IIR filter using bilinear transformation method

Butterworth filter design

(a) List the given parameters and draw the response of the filter. Next convert the given digital datas intoanalog using the transformation techniques.

(b) Since at high frequency 0 differs from OJ in bilinear transformation method first prewarpanalog n.

o=~tan(~)

(c) Calculate the order ofthe filter (analog LPF)A

log-N~--£- ~ LPF and HPF

log n,Op

Page 145: Dsp Matlab & Two Marks

TQA·102 • Digital Signal Processing

Alog-

N "C.__ 1':_ 4 BPF and BEFlogq.

where,

1':=(IOOlal' -lt5

A = (]00 la, - I t5Os = Stop band frequency

°p = Pass band frequency

Or = min{IAI, IBI} and

A = -of +O,Ou . B = -O~+O,Ouodou -od' O2 [Ou -od

(d) Based on the order of the filter choose the butterworth polynomial.

IH(s)=--­Polynomial

(e) Convert normalized LPF into de-normalized respective filter.

For denormalized,

SLPF S4-

~.

HPF S4 ~S

S2 +q OuBPFS4---­S(Ou -q)

BEF S 4 S[Ou -q]S2qOu

°Where () =-p,'t' I

eN

(t) Convert the analog filter into respective digital filter using bilinear transformation method by replacing S

2(l-z-l)

by T(l+z-I) inH(s).

(g) Same procedure is followed for Chebysher filter except there is no standard polynomial to look up as incase of Butterworth. Here the transfer function has to be derived.

Page 146: Dsp Matlab & Two Marks

Chapter 9 Analysis of Finite Word Length Effect

1. Using Laplace transform, find the impulse response of an LTI system described by a differential equation

d2 y(t) _ dy(t) _ 2y(t) = x(t).dt2 dt

Solution d2 y(t) _ dy(t) _ 2y(t) = x(t)dt2 dt

Apply Laplace transform,

s2 Y(s) - s Y(s) - 2Y(s) = x(s)

Y(s)[s2 -s-2 ]=x(s)

Y(s) = H(s)X(s)

1=s2 -s,-2

The impulse response can be calculated asI

H(s)=---­, (s-2) (s+l)

A B=--+­s-2 s+1

A = (s - 2) H(s)ls=+2

= S ~ 11'\'=+2

1 1=-=-2+1 3

B=(s+l) H(s)ls=_1

= s~2Is=_1

1 1=--=---1-2 3

1 1- --H(s) =_3_+_3s-2 s+1

The impulse response is given by

Page 147: Dsp Matlab & Two Marks

TQA·104 • Digital Signal Processing

. . 2s2 +9s-472. FlOd the lOverse Laplace transform of X(s) = 2 •

(s +6s+25)Solution

X(s) = 2s2 +9s-47(s2 +6s+25)

2s2 +9s-47=(s+3+ )4) (s+3- )4)

A B=----+----(s+3+)4) (s+3-)4)

A = (s + 3+ )4)X(s)I"=_3_}4

= 2(-3- )4)2 +9(-3- )4)-47(-3- )4+3- )4)

= -1.5- )11

B = (s+3- )4)X(s)i"=_3+}4

2(-3+ )4)2 +9(-3+ )4)-47=---------(-3+ )4+3+ )4)

= -1.5+ )11

X(s) = -1.5- )11 + -1.5+ )11s+3+)4 s+3-)4

The inverse Laplace is,

x(t) = (-1.5 - )11)e-(3+j4)t u(t) + (-1.5 + )11)e-(3- }4)t u(t)

3. Draw the direct form-II realization ofthe system described by the differential equation

d2 y(t) + 5 dy(t) + 4y(t) = dx(t) .~2 ~ ~

Solution d2 y(t) + 5 dy(t) + 4y(t) = dx(t)dt2 dt dt

y(t)

Page 148: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·105

Taking Laplace transform

S2y(S) + 5sY(s) +4Y(s) = sX(s)

Y(S)[S2 +5s +4] = sX(s)

Y(s) s--=----X(s) s2+5s+4

4. What is the effect of quantization on pole locations?

Solution Quantization of coefficients in digital filters lead to slight changes in their value. This change invalue offilter coefficients modify the pole-zero locations. Sometimes the pole locations will be changed in sucha way that the system may drive into unstability.

5. What is truncation error?

Solution The error occuring while truncating long sequence is called truncation error. If the number x is

truncated to Xr by b number of bits, then the truncation error Xr -x satisfies the inequality, 0 ~ xr -x> z-b .

6. What is the transfer function of a system whose poles are at -0.3 ± jOA and a zero at - 0.2?Solution

H(s) = (s+0.2)(s +0.3 + jOA) (s +0.3 - jOA)

Page 149: Dsp Matlab & Two Marks

Chapter 13 State Variables

l. Find the state variable matrices A, B, C and D for the input-output relation given by the relation

y(n) = 6y(n -1) + 4y(n- 2)+ x(n)+ 10x(n -1)+ 12x(n-12) .

Solution y(n) = 6y(n -1) +4y(n - 2)+ x(n) + 10x(n -1) + 12x(n -12)

Take Z-transform,

Y(Z) = 6rlY(Z)+4r2Y(Z)+X(Z)+10rIX(Z)+ 12r2X(Z)

Y(Z)[1-6rl-4z-2]=X(Z)[1+10Z-' +12r2]

Y(Z) 1+ lOr' + 12r2

X(Z) = 1-6rl-4r2The direct form-II structure is

The state equation by considering input-output state

q,(n + 1)= 6q,(n) + 4q2(n) + x(n)

q2(n+ 1) = q,(n)

The output of the system is,

y(n)

(1)

(2)

y(n) = x(n)+ 6ql (n)+ 4q2(n)+ 10q,(n)+ 12q2(n)

y(n) = 16q,(n)+ 16q2(n)+ x(n)

The state matrix becomes,

[q,(n. +1)]=[6 4][I]x(n)q2(n+l) 1 0 0

[ [ql (n)]y(n) = 16 16] +[1] x(n)

q2(n)

(3)

(4)

(5)

Page 150: Dsp Matlab & Two Marks

Two Marks Questions and Answers • TQA·107

From equation (4) and (5)

A=[~ ~lB=[~lC=[16 16];D=[1]

2. A continuous-time system has the state variable description A = [~ ~ 1]; B = [ ~]; C = [3 1]; D = [2] .Determine the transfer function.

Solution

H(s) = C[sI - Arl B + D (1)

Let us consider, sf - A

[1 0] [2 -1]sf - A = sOl - 1 0

= [~ ~]_[~ ~1]

= [S - 2 1]-1 s

[sf- Arl = Adj [sf- A]Det [sf- A]

[s -1]= 1 s-2s(s - 2)+ 1

[: s~12]=----s2 -2s+ 1

=[S2 -~S+Is2 - 2s+ 1

Substitute equation (2) in (1),

-1 j

s2-2s+1

s-2

s2-2s+1

(2)

-3 s-2 ][1] []s2 _ 2s + 1+ s2 - 2s + 1 0 + 2

H(s) = [3 1][s2 -~S+1 S2 --;s+ 1] [1]+[2]

1 s-2 0

s2 - 2s + 1 s2 - 2s + 1

_ [ __ 3_S _+ __1__- s2-2s+1 s2-2s+1

Page 151: Dsp Matlab & Two Marks

TQA·108 • Digital Signal Processing

_[ 3s+1 s-5 ][1]+[2]- s2-2s+1 s2-2s+1 0

= 3s+1 +2i -2s+1

3s+1+2(s2 -2s+1)=-------s2 - 2s+ 1

2

H(s) = Y(s) 2s -s+3X(S)S2_2s+1

Y(S) 2s2 -s+3--=X(S) s2-2s+1

S2Y(s)-2sY(s)+ Y(S) = 2i X(s)-sX(s)+3X(s)

Take inverse Laplace transform,

d2 y(t) _ 2 dy(t) + y(t) = 2 d2 x(t) _ dx(t) + 3x(t)dt2 dt dt2 dt