Você está na página 1de 46

Electronics and Communication Department

Class : 7
th
Sem Subject : Digital Signal Processing
Practical No. 1 (A) Subject Code : 17100
Aim:! To study DSP commands used in MATLAB
Some of the frequently used DSP commands are mentioned and explained belo!
1. stem
Plots discrete sequence data
S"nta#
stem"#$
stem"%&#$
stem"'''&(fill($
stem"'''&LineSpec$
h ) stem"'''$
Descri$tion
A to*dimensional stem plot displays data as lines extendin+ from the x*axis' A circle "the default$
or other mar,er hose y*position represents the data -alue terminates each stem'
Stem"#$ plots the data sequence # as stems that extend from equally spaced and automatically
+enerated -alues alon+ the x*axis' .hen # is a matrix& stem plots all elements in a ro a+ainst the
same x -alue'
stem"%&#$ plots % -ersus the columns of #' % and # are -ectors or matrices of the same si/e'
Additionally& % can be a ro or a column -ector and # a matrix ith len+th"%$ ros'
stem"'''&(fill($ specifies hether to color the circle at the end of the stem'
0
Electronics and Communication Department
%. &eros
Create an array of all /eros
S"nta#
B ) /eros"n$
B ) /eros"m&n$
B ) /eros"1m n2$
B ) /eros"d0&d3&d4'''$
B ) /eros"1d0 d3 d4'''2$
Descri$tion
B ) /eros"n$ returns an n*by*n matrix of /eros' An error messa+e appears if n is not a scalar'
B ) /eros"m&n$ or B ) /eros"1m n2$ returns an m*by*n matrix of /eros'
B ) /eros"d0&d3&d4'''$ or B ) /eros"1d0 d3 d4'''2$ returns an array of /eros ith dimensions d0*by*
d3*by*d4*by*''' '
B ) /eros"si/e"A$$ returns an array the same si/e as A consistin+ of all /eros'
. con'
Con-olution and polynomial multiplication
S"nta#
) con-"u&-$
Descri$tion
) con-"u&-$ con-ol-es -ectors u and -' Al+ebraically& con-olution is the same operation as
multiplyin+ the polynomials hose coefficients are the elements of u and -'
De(inition
Let m ) len+th"u$ and n ) len+th"-$' Then is the -ector of len+th m5n*0 hose kth element is
The sum is o-er all the -alues of 6 hich lead to le+al subscripts for u"6$ and -",50*6$& specifically 6
) max"0&,50*n$! min",&m$' .hen m ) n& this +i-es
"0$ ) u"0$7-"0$
"3$ ) u"0$7-"3$5u"3$7-"0$
"4$ ) u"0$
7
-"4$5u"3$7-"3$5u"4$7-"0$
'''
"37n*0$ ) u"n$7-"n$
3
Electronics and Communication Department
). *ength
Len+th of -ector
S"nta#
n ) len+th"%$
Descri$tion
The statement len+th"%$ is equi-alent to max"si/e"%$$ for nonempty arrays and 8 for empty arrays'
n ) len+th"%$ returns the si/e of the lon+est dimension of %' 9f % is a -ector& this is the same as its
len+th'
+. (ormat

Control the display format for output
,ra$hical -nter(ace
As an alternati-e to format& use preferences' Select Pre(erences from the .ile menu in the
MATLAB des,top and use Command /indo0 preferences'
S"nta#
format
format type
format"(type($
Descri$tion
MATLAB performs all computations in double precision' :se the format function to control the
output format of the numeric -alues displayed in the Command .indo' The format function
affects only ho numbers are displayed& not ho MATLAB computes or sa-es them' The specified
format applies only to the current session' To maintain a format across sessions& use MATLAB
preferences'
format by itself& chan+es the output format to the default type& short& hich is ;*di+it scaled& fixed*
point -alues'
4
Electronics and Communication Department
1alue (or
t"$e
2esult 3#am$le
5 5& *& blan, 5
Ban, <ixed dollars and cents 4'0=
compact Suppresses excess line feeds to sho more output in a
sin+le screen' Contrast ith loose'
theta ) pi>3
theta)0';?8@
Aex Aexadecimal =88B30fb;===3d0@
Lon+ 0;*di+it scaled fixed point 4'0=0;B3C;4;@B?B
lon+ e 0;*di+it floatin+ point 4'0=0;B3C;4;@B?B4e588
lon+ + Best of 0;*di+it fixed or floatin+ point 4'0=0;B3C;4;@B?B
Loose Adds linefeeds to ma,e output more readable' Contrast
ith compact'
theta ) pi>3
theta)0';?8@
Dat Datio of small inte+ers 4;;>004
Short ;*di+it scaled fixed point 4'0=0C
Short e ;*di+it floatin+ point 4'0=0Ce588
Short + Best of ;*di+it fixed or floatin+ point 4'0=0C
format"(type') is the function form of the syntax'
4. dis$
Display text or array
S"nta#
disp"%$
Description
disp"%$ displays an array& ithout printin+ the array name' 9f % contains a text
strin+& the strin+ is displayed'
Another ay to display an array on the screen is to type its name& but this prints a
leadin+ E% )&E hich is not alays desirable'
=
Electronics and Communication Department
7. /a'e(orms
a. $ulstrain
Fenerate a pulse train'
S"nta#
y ) pulstran"t&d&(func($
y ) pulstran"t&d&(func(&p0&p3&'''$
y ) pulstran"t&d&p&fs$
y ) pulstran"t&d&p$
Descri$tion
pulstran +enerates pulse trains from continuous functions or sampled prototype pulses'
y ) pulstran"t&d&(func($ +enerates a pulse train based on samples of a continuous function& (func(&
here (func( is!
(+auspuls(& for +eneratin+ a Faussian*modulated sinusoidal pulse
(rectpuls(& for +eneratin+ a sampled aperiodic rectan+le
(tripuls(& for +eneratin+ a sampled aperiodic trian+le
pulstran is e-aluated len+th"d$ times and returns the sum of the e-aluations
y ) func"t*d"0$$ 5 func"t*d"3$$ 5 '''
b. rect$uls
Fenerate a sampled aperiodic rectan+le'
S"nta#
y ) rectpuls"t$
y ) rectpuls"t&$
Descri$tion
y ) rectpuls"t$ returns a continuous& aperiodic& unity*hei+ht rectan+ular pulse at
the sample times indicated in array t& centered about t ) 8 and ith a default idth
of 0' Gote that the inter-al of non*/ero amplitude is defined to be open on the ri+ht&
that is& rectpuls"*8';$ ) 0 hile rectpuls"8';$ ) 8'
y ) rectpuls"t&$ +enerates a rectan+le of idth '
rectpuls is typically used in con6unction ith the pulse train +eneratin+ function
c. sa0tooth
Fenerate a satooth or trian+le a-e'
;
Electronics and Communication Department
S"nta#
x ) satooth"t$
x ) satooth"t&idth$
Descri$tion
satooth"t$ +enerates a satooth a-e ith period 3pi for the elements of time -ector t' satooth"t$
is similar to sin"t$& but creates a satooth a-e ith pea,s of *0 and 0 instead of a sine a-e' The
satooth a-e is defined to be *0 at multiples of 3pi and to increase linearly ith time ith a slope
of 0>pi at all other times'
satooth"t&idth$ +enerates a modified trian+le a-e here idth& a scalar parameter beteen 8
and 0& determines the point beteen 8 and 3pi at hich the maximum occurs' The function
increases from *0 to 0 on the inter-al 8 to 3pi7idth& then decreases linearly from 0 to *0 on the
inter-al 3pi7idth to 3pi'
5. .ourier trans(orm
a.t(%&$
Con-ert transfer function filter parameters to /ero*pole*+ain form'
S"nta#
1/&p&,2 ) tf3/p"b&a$
Descri$tion
tf3/p finds the /eros& poles& and +ains of a transfer function'
1/&p&,2 ) tf3/p"b&a$ finds the matrix of /eros /& the -ector of poles p& and the associated -ector of
+ains , from the transfer function parameters b and a!
The numerator polynomials are represented as columns of the matrix b'
The denominator polynomial is represented in the -ector a'
Fi-en a S9MH continuous*time system in polynomial transfer function form
or
you can use the output of tf3/p to produce the sin+le*input& multioutput "S9MH$ factored transfer
function form
or
C
Electronics and Communication Department
The folloin+ describes the input and output ar+uments for tf3/p!
The -ector a specifies the coefficients of the denominator polynomial A"s$ "or A"z$$ in
descendin+ poers of s "z
*0
$'
The ith ro of the matrix b represents the coefficients of the ith numerator polynomial "the
ith ro of B"s$ or B"z$$' Specify as many ros of b as there are outputs'
<or continuous*time systems& choose the number nb of columns of b to be less than or equal
to the len+th na of the -ector a'
The /ero locations are returned in the columns of the matrix /& ith as many columns as
there are ros in b'
The pole locations are returned in the column -ector p and the +ains for each numerator
transfer function in the -ector ,'
b. &$%t(
Con-ert /ero*pole*+ain filter parameters to transfer function form'
S"nta#
1b&a2 ) /p3tf"/&p&,$
Descri$tion
/p3tf forms transfer function polynomials from the /eros& poles& and +ains of a system in factored
form'
1b&a2 ) /p3tf"/&p&,$ finds a rational transfer function
+i-en a system in factored transfer function form
Column -ector p specifies the pole locations& and matrix / specifies the /ero locations& ith as many
columns as there are outputs' The +ains for each numerator transfer function are in -ector ,' The
/eros and poles must be real or come in complex con6u+ate pairs' The polynomial denominator
coefficients are returned in ro -ector a and the polynomial numerator coefficients are returned in
matrix b& hich has as many ros as there are columns of /'
'
?
Electronics and Communication Department
c. residue
Con-ert beteen partial fraction expansion and polynomial coefficients
S"nta#
1r&p&,2 ) residue"b&a$
1b&a2 ) residue"r&p&,$
Descri$tion
The residue function con-erts a quotient of polynomials to pole*residue representation& and bac,
a+ain'
1r&p&,2 ) residue"b&a$ finds the residues& poles& and direct term of a partial fraction expansion of the
ratio of to polynomials& b(s) and a(s)& of the form!
1b&a2 ) residue"r&p&,$ con-erts the partial fraction expansion bac, to the polynomials ith
coefficients in b and a'
De(inition
9f there are no multiple roots& then!
The number of poles n is
n ) len+th"a$*0 ) len+th"r$ ) len+th"p$
The direct term coefficient -ector is empty if len+th"b$ I len+th"a$J otherise
len+th",$ ) len+th"b$*len+th"a$50
9f p"6$ ) ''' ) p"65m*0$ is a pole of multiplicity m& then the expansion includes terms of the form
@
Electronics and Communication Department
Arguments
b&a Kectors that specify the coefficients of the polynomials in descendin+ poers of s
r Column -ector of residues
p Column -ector of poles
L Do -ector of direct terms
6. clc ! Clears all input and output from the Command .indo display& +i-in+ you
a Eclean screen'E

10. clear ! remo-es all -ariables from the or,space' This frees up system memory'
11. clear all ! same as clear'
1%. clear name ! remo-es 6ust the M*file or ME%*file function or -ariable name from the
or,space'
Defer help for more on clear'
1' sub$lot ! subplot di-ides the current fi+ure into rectan+ular panes that are numbered
roise' Each pane contains an axes ob6ect' Subsequent plots are output to
the current pane'
Defer help for more on subplot'
16. $lot ! Plots 3*D line plot' Defer help for -arious syntaxes and use of plot'
%0. title ! Add title to current axes' Defer help for -arious syntaxes and use of title'
%1. "label ! labels the y*axis of the current axes'
%%. #label ! labels the x*axis of the current axes'
%. grid on ! adds ma6or +rid lines to the current axes'
%). grid o(( ! remo-es ma6or and minor +rid lines from the current axes'
%+. in$ut !
user7entr" 8 in$ut(9$rom$t9) !displays prompt as a prompt on the screen& aits for input
from the ,eyboard& and returns the -alue entered in userMentry'
user7entr" 8 in$ut(9$rom$t9:9s9) returns the entered strin+ as a text -ariable rather than as a
-ariable name or numerical -alue'
The response to the input prompt can be any MATLAB expression& hich is e-aluated usin+
the -ariables in the current or,space'
B
Electronics and Communication Department
Commands use(ul (or generating basic signals.
%4. ones : Create array of all ones' <or more on ones& refer MATLAB help'
%7.&eros : Create array of all /eros' <or more on /eros& refer MATLAB help'
B ) /eros"n$ returns an n*by*n matrix of /eros' An error messa+e appears if n is not a
scalar'
B ) /eros"m&n$ or B ) /eros"1m n2$ returns an m*by*n matrix of /eros'
<or& other functions on /eros& refer to MATLAB help'
!
d.((t
Hne*dimensional fast <ourier transform
S"nta#
# ) fft"%$
# ) fft"%&n$
# ) fft"%&12&dim$
# ) fft"%&n&dim$
De(inition
The functions % ) fft"x$ and x ) ifft"%$ implement the transform and in-erse transform pair +i-en
for -ectors of len+th N by!
here
is an Nth root of unity'
Descri$tion
# ) fft"%$ returns the discrete <ourier transform "D<T$ of -ector %& computed ith a fast <ourier
transform "<<T$ al+orithm'
9f % is a matrix& fft returns the <ourier transform of each column of the matrix'
9f % is a multidimensional array& fft operates on the first nonsin+leton dimension'
# ) fft"%&n$ returns the n*point D<T' 9f the len+th of % is less than n& % is padded ith trailin+ /eros
to len+th n' 9f the len+th of % is +reater than n& the sequence % is truncated'
08
Electronics and Communication Department
3#am$les
A common use of <ourier transforms is to find the frequency components of a si+nal buried in a
noisy time domain si+nal' Consider data sampled at 0888 A/' <orm a si+nal containin+ ;8 A/ and
038 A/ and corrupt it ith some /ero*mean random noise!
t ) 8!8'880!8'CJ
x ) sin"37pi7;87t$5sin"37pi70387t$J
y ) x 5 37randn"si/e"t$$J
plot"y"0!;8$$
title"(Si+nal Corrupted ith Nero*Mean Dandom Goise($
xlabel"(time "seconds$($
9t is difficult to identify the frequency components by loo,in+ at the ori+inal si+nal' Con-ertin+ to
the frequency domain& the discrete <ourier transform of the noisy si+nal y is found by ta,in+ the
;03*point fast <ourier transform "<<T$!
# ) fft"y&;03$J
The poer spectrum& a measurement of the poer at -arious frequencies& is
Pyy ) #'7 con6"#$ > ;03J
Fraph the first 3;? points "the other 3;; points are redundant$ on a meanin+ful frequency axis'
f ) 08887"8!3;C$>;03J
plot"f&Pyy"0!3;?$$
title"(<requency content of y($
xlabel"(frequency "A/$($
00
Electronics and Communication Department
This represents the frequency content of y in the ran+e from DC up to and includin+ the Gyquist
frequency' "The si+nal produces the stron+ pea,s'$
e. i((t
9n-erse one*dimensional fast <ourier transform
S"nta#
y ) ifft"%$
y ) ifft"%&n$
y ) ifft"%&12&dim$
y ) ifft"%&n&dim$
Descri$tion
y ) ifft"%$ returns the in-erse discrete <ourier transform "D<T$ of -ector %& computed ith a fast
<ourier transform "<<T$ al+orithm'
9f % is a matrix& ifft returns the in-erse D<T of each column of the matrix'
9f % is a multidimensional array& ifft operates on the first non*sin+leton dimension'
y ) ifft"%&n$ returns the n*point in-erse D<T of -ector %'
y ) ifft"%&12&dim$ and y ) ifft"%&n&dim$ return the in-erse D<T of % across the dimension dim'
<or any %& ifft"fft"%$$ equals % to ithin roundoff error' 9f % is real& ifft"fft"%$$ may ha-e small
ima+inary parts'
03
Electronics and Communication Department
4. .ilters
a. butta$
Butterorth analo+ lopass filter prototype'
S"nta#
1/&p&,2 ) buttap"n$
Descri$tion
1/&p&,2 ) buttap"n$ returns the poles and +ain of an order n Butterorth analo+ lopass filter
prototype' The function returns the poles in the len+th n column -ector p and the +ain in scalar ,' /
is an empty matrix because there are no /eros' The transfer function is
Butterorth filters are characteri/ed by a ma+nitude response that is maximally flat in the passband
and monotonic o-erall' 9n the lopass case& the first 3n*0 deri-ati-es of the squared ma+nitude
response are /ero at ) 8' The squared ma+nitude response function is
correspondin+ to a transfer function ith poles equally spaced around a circle in the left half plane'
The ma+nitude response at the cutoff frequency 8 is alays re+ardless of the filter order'
buttap sets 8 to 0 for a normali/ed result'
Algorithm
/ ) 12J
p ) exp"sqrt"*0$7"pi7"0!3!37n*0$>"37n$5pi>3$$'(J
, ) real"prod"*p$$J
b. cheb1a$
Chebyshe- type 9 analo+ lopass filter prototype'
S"nta#
1/&p&,2 ) cheb0ap"n&Dp$
Descri$tion
1/&p&,2 ) cheb0ap"n&Dp$ returns the poles and +ain of an order n Chebyshe- type 9 analo+ lopass
filter prototype ith Dp dB of ripple in the passband' The function returns the poles in the len+th n
column -ector p and the +ain in scalar ,' / is an empty matrix& because there are no /eros' The
transfer function is
04
Electronics and Communication Department
Chebyshe- type 9 filters are equiripple in the passband and monotonic in the stopband' The poles
are e-enly spaced about an ellipse in the left half plane' The Chebyshe- type 9 cutoff frequency
is set to 0'8 for a normali/ed result' This is the frequency at hich the passband ends and the filter
has ma+nitude response of 08
*Dp>38
'
c.reme&ord
Par,s*McClellan optimal <9D filter order estimation'
S"nta#
1n&fo&ao&2 ) reme/ord"f&a&de-$
1n&fo&ao&2 ) reme/ord"f&a&de-&fs$
Descri$tion
1n&fo&ao&2 ) reme/ord"f&a&de-$ finds the approximate order& normali/ed frequency band ed+es&
frequency band amplitudes& and ei+hts that meet input specifications f& a& and de-'
f is a -ector of frequency band ed+es "beteen 8 and fs>3& here fs is the samplin+
frequency$& and a is a -ector specifyin+ the desired amplitude on the bands defined by f' The
len+th of f is to less than tice the len+th of a' The desired function is pieceise constant'
de- is a -ector the same si/e as a that specifies the maximum alloable de-iation or ripples
beteen the frequency response and the desired amplitude of the output filter for each band'
:se reme/ ith the resultin+ order n& frequency -ector fo& amplitude response -ector ao& and
ei+hts to desi+n the filter b hich approximately meets the specifications +i-en by reme/ord
input parameters f& a& and de-'
b ) reme/"n&fo&ao&$
1n&fo&ao&2 ) reme/ord"f&a&de-&fs$ specifies a samplin+ frequency fs' fs defaults to 3 A/& implyin+ a
Gyquist frequency of 0 A/' #ou can therefore specify band ed+es scaled to a particular application(s
samplin+ frequency'
9n some cases reme/ord underestimates the order n' 9f the filter does not meet the specifications& try
a hi+her order such as n50 or n53'
c ) reme/ord"f&a&de-&fs&(cell($ +enerates a cell*array hose elements are the parameters to reme/'
0=
Electronics and Communication Department
d.;aiserord
Estimate parameters for an <9D filter desi+n ith a Laiser indo'
S"nta#
1n&.n&beta&ftype2 ) ,aiserord"f&a&de-$
1n&.n&beta&ftype2 ) ,aiserord"f&a&de-&fs$
c ) ,aiserord"f&a&de-&fs&(cell($
Descri$tion
,aiserord returns a filter order n and beta parameter to specify a Laiser indo for use ith the fir0
function' Fi-en a set of specifications in the frequency domain& ,aiserord estimates the minimum
<9D filter order that ill approximately meet the specifications' ,aiserord con-erts the +i-en filter
specifications into passband and stopband ripples and con-erts cutoff frequencies into the form
needed for indoed <9D filter desi+n'
1n&.n&beta&ftype2 ) ,aiserord"f&a&de-$ finds the approximate order n& normali/ed frequency band
ed+es .n& and ei+hts that meet input specifications f& a& and de-' f is a -ector of band ed+es and a
is a -ector specifyin+ the desired amplitude on the bands defined by f' The len+th of f is tice the
len+th of a& minus 3' To+ether& f and a define a desired pieceise constant response function' de- is
a -ector the same si/e as a that specifies the maximum alloable error or de-iation beteen the
frequency response of the output filter and its desired amplitude& for each band' The entries in de-
specify the passband ripple and the stopband attenuation' #ou specify each entry in de- as a positi-e
number& representin+ absolute filter +ain "not in decibels$'
fir0 can use the resultin+ order n& frequency -ector .n& multiband ma+nitude type ftype& and the
Laiser indo parameter beta' The ftype strin+ is intended for use ith fir0J it is equal to (hi+h( for
a hi+hpass filter and (stop( for a bandstop filter' <or multiband filters& it can be equal to (dc*8( hen
the first band is a stopband "startin+ at f ) 8$ or (dc*0( hen the first band is a passband'
To desi+n an <9D filter b that approximately meets the specifications +i-en by ,aiser parameters f& a&
and de-& use the folloin+ command'
b ) fir0"n&.n&,aiser"n50&beta$&ftype&(noscale($
1n&.n&beta&ftype2 ) ,aiserord"f&a&de-&fs$ uses a samplin+ frequency fs in A/' 9f you don(t specify the
ar+ument fs& or if you specify it as the empty -ector 12& it defaults to 3 A/& and the Gyquist
frequency is 0 A/' #ou can use this syntax to specify band ed+es scaled to a particular application(s
samplin+ frequency'
c ) ,aiserord"f&a&de-&fs&(cell($ is a cell*array hose elements are the parameters to fir0'
The desi+n formulas that underlie the Laiser indo and its application to <9D filter desi+n are
here ) *38lo+08 is the stopband attenuation expressed in decibels "recall that p ) s is
required$'
0;
Electronics and Communication Department
The desi+n formula is
here n is the filter order and is the idth of the smallest transition re+ion'
e. butter
Butterorth analo+ and di+ital filter desi+n'
S"nta#
1b&a2 ) butter"n&.n$
1b&a2 ) butter"n&.n&(ftype($
1b&a2 ) butter"n&.n&(s($
1b&a2 ) butter"n&.n&(ftype(&(s($
1/&p&,2 ) butter"'''$
1A&B&C&D2 ) butter"'''$
Descri$tion
butter desi+ns lopass& bandpass& hi+hpass& and bandstop di+ital and analo+ Butterorth filters'
Butterorth filters are characteri/ed by a ma+nitude response that is maximally flat in the passband
and monotonic o-erall'
Butterorth filters sacrifice rolloff steepness for monotonicity in the pass* and stopbands' :nless
the smoothness of the Butterorth filter is needed& an elliptic or Chebyshe- filter can +enerally
pro-ide steeper rolloff characteristics ith a loer filter order'
7. Con'olution.
0 8 con'(u:') con-ol-es -ectors u and -' Al+ebraically& con-olution is the same operation as
multiplyin+ the polynomials hose coefficients are the elements of u and -'
De(inition
Let m 8 length(u) and n 8 length(').
Then is the -ector of len+th m5n*0 hose ,th element is
Notes :
a. 9n matlab& the time index starts from 0 instead of 8& so& v(k+1-j) is used instead of
v(k-j).
b. The sum is o-er all the -alues of 6'
c. .here 6 has the ran+e < j 8 ma#(1:;=1!n): min(;:m) >.
d. /hen m 8 n: this +i-es
"0$ ) u"0$7-"0$
"3$ ) u"0$7-"3$5u"3$7-"0$
"4$ ) u"0$7-"4$5u"3$7-"3$5u"4$7-"0$
'''
0C
Electronics and Communication Department
"n$ ) u"0$7-"n$5u"3$7-"n*0$5 ''' 5u"n$7-"0$
'''
"37n*0$ ) u"n$7-"n)
Algorithm
The con-olution theorem says& rou+hly& that con-ol-in+ to sequences is the same as
multiplyin+ their <ourier transforms' 9n order to ma,e this precise& it is necessary to pad the
to -ectors ith /eros and i+nore roundoff error' Thus& if % ) fft"1x /eros"0&len+th"y$*0$2$
and # ) fft"1y /eros"0&len+th"x$*0$2$ then con-"x&y$ ) ifft"%'7#$
See Alsocon-3& con-n& decon-& filter con-mtx and xcorr in the Si+nal Processin+ Toolbox
5. dis$ : Dis$la" te#t or arra"
disp"%$ displays an array& ithout printin+ the array name' 9f %
contains a text strin+& the strin+ is displayed'
Another ay to display an array on the screen is to type its name& but
this prints a leadin+ E% )&E hich is not alays desirable'
0?
Electronics and Communication Department
Practical No: !! 1( B )
Aim:! To study Si+nal Processin+ Toolbox'
Signal Processing ?oolbo# @'er'ie0
Si+nal Processin+ Toolbox is a collection of tools based on the MATLABO numeric computin+
en-ironment' The toolbox supports a ide ran+e of si+nal processin+ operations& from a-eform
+eneration to filter desi+n and implementation& parametric modelin+& and spectral analysis' The
toolbox pro-ides to cate+ories of tools& command*line functions and +raphical :ser interfaces!
Command!*ine .unctions
Command*line functions are a-ailable in the folloin+ cate+ories!
Discrete*time filter desi+n& analysis& and implementation
Analo+ filter desi+n& analysis& and implementation
Linear system transformations
.indos
Spectral analysis and cepstral analysisTransformsStatistical si+nal processin+
Parametric modelin+
Linear prediction
Multirate si+nal processin+
.a-eform +eneration
,ra$hical Aser -nter(aces
A suite of interacti-e +raphical user interfaces are a-ailable for
<ilter desi+n and analysis
.indo desi+n and analysis
Si+nal plottin+ and analysis& spectral analysis& and filterin+
Note: Students are ad-ised to refer the material a-ailable in this topic in MATLAB help& as and
hen required'
0@
Electronics and Communication Department

Class : 7
th
Sem Subject : Digital Signal Processing
Practical No. % Subject Code : 17100
A-B! To Fenerate <olloin+ .a-eforms'
0' :nit step
3' Damp
4' Exponential
=' :nit impulse
clcJ
clear allJ
t)8!8';!;J
+0)ones"08&0$J Pfunction for unit step fun'
+3)tJ Pfunction for ramp fun'
+4)exp"t$J Pfunction for exponentional fun'
+=)10J/eros"088&0$2J Pfunction for unit impulse fun'
Pthe folloin+ instruction ill plot the unit step function
subplot"3&3&0$Jstem"+0&(r($J
title"(unit step function($J
Pthe folloin+ instruction ill plot the ramp function
subplot"3&3&3$Jstem"+3&(b($J
title"(ramp function($J
Pthe folloin+ instruction ill plot the exponentional step function
subplot"3&3&4$Jstem"+4&(+($J
title"(unit exponentional function($J
Pthe folloin+ instruction ill plot the unit impulse function
subplot"3&3&=$Jstem"+=&(b($J
title"(unit impluse function($J
0B
Electronics and Communication Department
38
Electronics and Communication Department

Class : 7
th
Sem Subject : Digital Signal Processing
Practical No. Subject Code : 17100
Samplin+ and Deconstruction'
Aim ! To +enerate the sampled data sequence from analo+ sequence and then reconstruct the
ori+inal analo+ si+nal from its samples usin+ interpolation formula'
Samplin+ Theorem ! The si+nal can be reconstructed from its samples& if it ere sampled at a rate
more than or equal to double the hi+hest frequency presents in the analo+ si+nal hich as
sampled'
The sampled sequence is represented by&
x"n$ ) x"t$Q t)nTs& .here Ts is samplin+ inter-al ) 0>fs' RRRRRRRRR''"0$
The reconstruction formula usin+ sinc function as reconstructor is&
x"t$ )

n
nTs t Fs c n x $2 " 1 sin $ "
' RRRRRRRRRRRRRRRRRR"3$
9t means& x"t$ can be reconstructed& pro-ided x"n$ is finite duration sequenceJ i'e' Sx"n$& n0

n3T'
9n MATLAB continuous time t can be implemented on a -ery fine +rid ith the +rid inter-al

t'
x"m

t$ )

=

n
nTs Fs c n x $2 t m " 1 sin $ "
' t0

t3' RRRRR"4$
9n eq'"4$&
x"n$ is ra -ector of len+th ) G ) len+th"n$J i'e' dimension ) 0xG
x"m

t$ is ra -ector of len+th ) M ) len+th"t$ J i'e' dimension ) 0xM


Thus&
sinc function ).)
$2 t m " 1 sin nTs Fs c
must be a matrix of dimension GxM&
so that multiplication of -ector x and -ector . can be done to obtain -ector x"m

t$'
Thus& abo-e equation can be implemented in MATLAB as matrix multiplication as follos'
xa)x7sinc"<s7"ones"len+th"n$&0$7t*nTs(7ones"0&len+th"t$$$$J
ones"len+th"n$&0$7t con-erts 0xM matrix t into GxM matrix
ones"len+th"n$&0$ ) Gx0 and t ) 0xM
and
nTs(7ones"0&len+th"t$$ con-erts 0xG matrix nTs into GxM matrix&
nTs( ) Gx0 and ones"0&len+th"t$$ ) 0xM '
so that these to matrices can be subtracted to obtain resultant . matrix of dimension GxM'
30
Electronics and Communication Department
Pro+ram !
PPro+ram to chec,
P 0$reconstruction of sampled si+nal 3$effect of samplin+ rate on
P reconstructed si+nal'
PThe si+nal to be sampled is exponential si+nal&
P x"t$)exp"*a7t$& here a)0888 and t)1*;ms& ;ms2'

PChec, for samplin+ frequency of ; LA/ and 0 LA/'
clcJ
clear allJ
close allJ
P**************************************************************************
PDescrete time Si+nal
tmax);>0888J P tmax); ms'
fs)input"(Enter the samplin+ frequency in LA/!($J
<s)fs70888J
Ts)0><sJn0)"tmax>Ts$J Pn0) no' of samples on both sides of -ertical axis
n)*n0!0!n0J Pn) index of descrete si+nal'
nTs)n7TsJ
x)exp"*08887abs"nTs$$J
P**************************************************************************
PAnalo+ si+nal reconstruction
Dt)tmax>088J P Kery fine +rid inter-al hich is used to simulate sinc1<s"t*n7Ts$2
t)*tmax!Dt!tmaxJ P *tmax ms to 5tmax ms time inter-al of continouos si+nal'
Plen+th"t$
xa)x7sinc"<s7"ones"len+th"n$&0$7t*nTs(7ones"0&len+th"t$$$$J
P**************************************************************************
PChec,
maxMerror)max"abs"xa*exp"*08887abs"t$$$$
PPlots of sampled and reconstructed si+nals'
subplot"3&0&0$J stem"n&x$J
xlabel"(n($J
ylabel"(x0"n$($Jtitle"1(Descrete Si+nal*Samplin+ freq ) ( num3str"fs$ ( LA/(2$Jhold on

subplot"3&0&3$J plot"t70888&xa$J
xlabel"(Time in mSec($J ylabel"(x"t$($Jtitle"(Deconstructed si+nal * x"t$($J
33
Electronics and Communication Department
9GP:T! <or samplin+ frequency ) 0 LA/
Enter the samplin+ frequency in LA/!0
maxMerror )
8'0@;3
@A?PA?:
-5 -4 -3 -2 -1 0 1 2 3 4 5
0
0.5
1
n
x
1
(
n
)
Descrete Signal-Sampling freq = 1 KHz
-5 -4 -3 -2 -1 0 1 2 3 4 5
-0.5
0
0.5
1
Time in mSec
x
(
t
)
Reconstructed signal - x(t)
34
Electronics and Communication Department
-NPA?: .or sam$ling (reCuenc" 8 + DE&
Enter the samplin+ frequency in LA/!;
maxMerror )
8'84@8
@A?PA?:
-25 -20 -15 -10 -5 0 5 10 15 20 25
0
0.5
1
n
x
1
(
n
)
Descrete Signal-Sampling freq = 5 KHz
-5 -4 -3 -2 -1 0 1 2 3 4 5
0
0.5
1
Time in mSec
x
(
t
)
Reconstructed signal - x(t)
C@NC*AS-@N:
3=
Electronics and Communication Department

Class : 7
th
Sem Subject : Digital Signal Processing
Practical No. ) Subject Code : 17100
PPDHFDAM TH CHMP:TE AGD PLHT L9GEAD CHGKHL:T9HG H< T.H <9G9TE
SEU:EGCES
P:S9GF CHGK <:GC9THG'
P Linear Con-olution of to sequences
P To compute linear con-olution of to sequences and plot sequences and output
P sequences'
P**************************************************************************
P Try folloin+ sequences
P x"n$)10 3 *0 02 V h"n$)10 3 *02
clcJ
clear allJ
m)input"(no of samples of x"n$!($J
x)/eros"0&m$J
for 6)0!m
x"0&6$)input"1(x"(&num3str"6$&($ ! (2$J
end
n)input"(no of samples of h"n$!($J
h)/eros"0&n$J
for 6)0!n
h"0&6$)input"1(h"(&num3str"6$&($ ! (2$J
end
y)con-"x&h$J
Pn0)0!len+th"y$J
subplot"4&0&0$J
stem"x$J axis"10 m5n*0 *max"abs"x$$ max"abs"x$$2$J
xlabel"(n($J
ylabel"(x"n$($J
title"(x"n$($J
subplot"4&0&3$J
stem"h$J axis"10 m5n*0 *max"abs"h$$ max"abs"h$$2$J
xlabel"(n($J
ylabel"(h"n$($J
title"(h"n$($J
subplot"4&0&4$J
stem"y$J axis"10 m5n*0 *max"abs"y$$ max"abs"y$$2$J
xlabel"(n($J
ylabel"(y"n$($J
title"(y"n$($J
3;
Electronics and Communication Department
disp"(y"n$)($J
disp"y$J
9GP:T!
no of samples of x"n$!=
x"0$ ! 0
x"3$ ! 3
x"4$ ! *0
x"=$ ! 0
no of samples of h"n$!4
h"0$ ! 0
h"3$ ! 3
h"4$ ! *0
y"n$)
0 = 3 *4 4 *0
H:TP:T!
1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6
-2
0
2
n
x
(
n
)
x(n)
1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6
-2
0
2
n
h
(
n
)
h(n)
1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6
-4
-2
0
2
4
n
y
(
n
)
y(n)
CHGCL:S9HG!
3C
Electronics and Communication Department

Class : 7
th
Sem Subject : Digital Signal Processing
Practical No. +(A) Subject Code : 17100
Exp;M0 ! Determination of /eros and poles form rational / Wtransform of a system function'
:se of folloin+ functions form si+nal processin+ tool box'
tf3/p ! Con-ert transfer function filter parameters to /ero*pole*+ain form'
Syntax ! 1/&p&,2 ) tf3/p"b&a$
Description! tf3/p finds the /eros& poles& and +ains of a continuous*time transfer function'
The numerator polynomials are represented as columns of the matrix b' The denominator
polynomial is represented in the column -ector a'
Gote ! #ou should use tf3/p hen or,in+ ith positi-e poers "s3 5 s 5 0$& such as in
continuous*time transfer functions'
A similar function& tf3/p,& is more useful hen or,in+ ith transfer functions expressed in in-erse
poers "0 5 /*0 5 /*3$& hich is ho transfer functions are usually expressed in DSP'
<or continuous*time systems ! number nb of columns of numerator polynomial b X the len+th na of
the denominator polynomial -ector a'
<or discrete*time systems ! number nb of columns of numerator polynomial b ) the
len+th na of the denominator polynomial -ector a'
#ou can use the function eqtflen+th to pro-ide equal len+th -ectors in the case that b and a are
-ectors of unequal len+ths'
eqtflen+th! Ma,e the len+ths of a transfer function(s numerator and denominator equal
Syntax ! 1b&a2 ) eqtflen+th"num&den$
1b&a&n&m2 ) eqtflen+th"num&den$
Description! The -ector num represents the numerator polynomial'
The -ector den represents its denominator polynomial'
1b&a2 ) eqtflen+th"num&den$ modifies the -ector num and>or the -ector den& so that the resultin+
output -ectors b and a ha-e the same len+th'
The resultin+ numerator b and denominator a represent the same discrete*time transfer function& but
these -ectors ha-e the same len+th'
3?
Electronics and Communication Department
1b&a&n&m2 ) eqtflen+th"num&den$ modifies the -ectors as abo-e and also returns the numerator order
n and the denominator m& not includin+ any trailin+ /eros'
The /ero locations are returned in the columns of the matrix /& ith as many columns as there are
ros in b'
The pole locations are returned in the column -ector p and the +ains for each numerator transfer
function in the -ector ,'
Problem ! <ind out the poles& /eros and +ain of folloin+ transfer functions'
0'
0
0
0

+ z
3'
0
0
0

z
4'
0
0
0
0

z
z
='
3 0
0
= ' 8 0
4 3

+ +
+
z z
z
Pro+ram!
P Determination of its /eroes V poles from rotational N*transform'
clcJ
clear allJ
b)input"(Enter the -alue of coeff of numerator)($J
a)input"(Enter the -alue of coeff of denominator)($J
1b&a2)eqtflen+th"b&a$J
1/&p&,2)tf3/p"b&a$J
disp"(Neros of Transfer <unction!($
disp"/$J
disp"(Poles of Transfer <unction!($
disp"p$J
disp"(Fain of Transfer <unction!($
disp",$J
3@
Electronics and Communication Department
Desults!
Command .indo!
0' Enter the -alue of coeff of numerator)0
Enter the -alue of coeff of denominator)10 02
Neros of Transfer <unction!
8
Poles of Transfer <unction!
*0
Fain of Transfer <unction!
0
3' Enter the -alue of coeff of numerator)0
Enter the -alue of coeff of denominator)10 *02
Neros of Transfer <unction!
8
Poles of Transfer <unction!
0
Fain of Transfer <unction!
0
4' Enter the -alue of coeff of numerator)10 *02
Enter the -alue of coeff of denominator)10 02
Neros of Transfer <unction!
0
Poles of Transfer <unction!
*0
Fain of Transfer <unction!
0
=' Enter the -alue of coeff of numerator)13 42
Enter the -alue of coeff of denominator)10 8'= 02
Neros of Transfer <unction!
8
*0';888
Poles of Transfer <unction!
*8'3888 5 8'B?B@i
*8'3888 * 8'B?B@i
Fain of Transfer <unction!
3
Conclusion!
3B
Electronics and Communication Department

Class : 7
th
Sem Subject : Digital Signal Processing
Practical No. +(B) Subject Code : 17100
Determination of rational / Wtransform from /eros and pole of a system function'
:se of folloin+ functions form si+nal processin+ tool box'
/p3tf ! Con-ert /ero*pole*+ain filter parameters to transfer function form'
Syntax ! 1num&den2 ) /p3tf"/&p&,$
Description! /p3tf forms transfer function polynomials from the /eros& poles& and +ains of a
system in factored form' 1num&den2 ) /p3tf"/&p&,$ finds a rational transfer function
The /ero locations are returned in the columns of the matrix /'
The pole locations are returned in the column -ector p and the +ains for each
numerator transfer function in the -ector ,'
Pro+ram!
P /*transform from poles& /eros and +ain'
clcJ
clear allJ
/)input"(Enter the -alue of /eroes in column -ector)($J
p)input"(Enter the -alue of poles in column -ector)($J
,)input"(Enter the -alue of +ain ,)($J
1b&a2)/p3tf"/&p&,$J
disp"(Gumerator Coeff' of Transfer <unction!($
disp"b$J
disp"(Denominator Coeff' of Transfer <unction!($
disp"a$J
48
Electronics and Communication Department
Desults!
Command .indo!
0' Enter the -alue of /eroes in column -ector)8
Enter the -alue of poles in column -ector)*0
Enter the -alue of +ain ,)0
Gumerator Coeff' of Transfer <unction!
0 8
Denominator Coeff' of Transfer <unction!
0 0
3' Enter the -alue of /eroes in column -ector)8
Enter the -alue of poles in column -ector)0
Enter the -alue of +ain ,)0
Gumerator Coeff' of Transfer <unction!
0 8
Denominator Coeff' of Transfer <unction!
0 *0
4' Enter the -alue of /eroes in column -ector)0
Enter the -alue of poles in column -ector)*0
Enter the -alue of +ain ,)0
Gumerator Coeff' of Transfer <unction!
0 *0
Denominator Coeff' of Transfer <unction!
0 0
=' Enter the -alue of /eroes in column -ector)18J*0';2
Enter the -alue of poles in column -ector)1*8'3888 5 8'B?B@iJ*8'3888 * 8'B?B@i2
Enter the -alue of +ain ,)3
Gumerator Coeff' of Transfer <unction!
3 4 8
Denominator Coeff' of Transfer <unction!
0'8888 8'=888 0'8888
".rite don the transfer functions for all abo-e four cases& and conclude$'
40
Electronics and Communication Department

Class : 7
th
Sem Subject : Digital Signal Processing
Practical No. 4 Subject Code : 17100
Computation of partial fraction expansion of a +i-en /*transform'
:se of folloin+ function form si+nal processin+ tool box'
residue/ ! con-erts a discrete time system& expressed as the ratio of to polynomials& to partial
fraction expansion& or residue& form'
Syntax ! 1r&p&,2 ) residue/"b&a$
Description! 1r&p&,2 ) residue/"b&a$ finds the residues& poles& and direct terms of a partial fraction
expansion of the ratio of to polynomials& b"/$ and a"/$' Kectors b and a specify the coefficients of
the polynomials of the discrete*time system b"/$>a"/$ in descendin+ poers of /'
n
n
m
m
z a z a z a a z a
z b z b z b b z b


+ + + + =
+ + + + =
''' $ "
''' $ "
0
3
0
0 8
3
3
0
0 8
Aere& m ) hi+hest poer on numerator
n ) hi+hest poer of denominator
9f there are no multiple roots and m Y n
$ " 0
0 0
$ 0 " ''' $ 3 " $ 0 "
$ " 0
$ "
'''
$ 0 " 0
$ 0 "
$ "
$ "
n m
z n m k z k k
z n p
n r
z p
r
z a
z b


+ + + + +

+ +

=
The returned column -ector r contains the residues& column -ector p contains the pole locations& and
ro -ector , contains the direct terms'
The number of poles is
n ) len+th"a$*0 ) len+th"r$ ) len+th"p$
9f mIn& there ill be no direct term'
9f m)n& there ill be one direct term'
9f mYn& there ill be m*n50 direct terms' <or example& if m)4& n)3& then there ill be 4*350)3
direct terms'
Problem ! <ind out the partial fraction expansion of folloin+ transfer functions'
0'
3 & 0 &
@
0
=
4
0
4
0
0
3 0
0
= =
+
+

n m
z z
z
3'
3 & 3 &
0; ' 8 3 ;
=
3 0
3 0
= =
+
+


n m
z z
z z
43
Electronics and Communication Department
Pro+ram!
P Pro+ram to perform partial fraction expantion of a +i-en /*transform'

P The function required is MATLAB function "r&p&,$) residue/"b&a$
P here& r ) column -ector +i-in+ residues
P p ) column -ector +i-in+ poles
P , ) ro -ector of direct terms
P b ) Do Kector that specify the coefficients of the
numerator polynomial of /*transform in descendin+
poer of /'
P a ) Do Kector that specify the coefficients of the
Denominator polynomial of /*transform'

clcJ
clear allJ

b ) input"(Enter coefficients of Gumerator polynomial of A"/$ !($J
a ) input"(Enter coefficients of Denomerator polynomial of A"/$ !($J
1D&p&,2)residue/"b&a$J

disp"(residues in * Dectan+ular Coordinates are !( $J disp"D$J
disp"(poles in * Dectan+ular Coordinates are !( $J disp"p$J
disp"(direct terms , are !( $J disp",$J
44
Electronics and Communication Department
Desults!
Command .indo!
0' Enter coefficients of Gumerator polynomial of A"/$ !10 0>42
Enter coefficients of Denomerator polynomial of A"/$ !10 *4>= 0>@2
residues in * Dectan+ular Coordinates are !
4'4444
*3'4444
poles in * Dectan+ular Coordinates are !
8';888
8'3;88
direct terms , are !
3' Enter coefficients of Gumerator polynomial of A"/$ !18 0 =2
Enter coefficients of Denomerator polynomial of A"/$ !1; *3 8'0;2
residues in * Dectan+ular Coordinates are !
0='4444
*=0'8888
poles in * Dectan+ular Coordinates are !
8'4888
8'0888
direct terms , are !
3C'CCC?
Conclusion! The partial fraction expansions computed usin+ MATLAB function are found as
follos!
0'
0 0
3 0
0
3; ' 8 0
4444 ' 3
; ' 8 0
4444 ' 4
@
0
=
4
0
4
0
0

=
+
+
z z
z z
z
and
3'
CCC? ' 3C
0 ' 8 0
8 ' =0
4 ' 8 0
44 ' 0=
0; ' 8 3 ;
=
0 0 3 0
3 0
+

=
+
+


z z z z
z z
Aence& e can find out the partial fraction expansion of rational / transform usin+
residue/ function'
4=
Electronics and Communication Department

Class : 7
th
Sem Subject : Digital Signal Processing
Practical No. 7 Subject Code : 17100
P Pro+ram to plot unit step and unit impulse response for the +i-en system'
P :se of function (filter('
clcJ
clear allJ
n)input"(Enter the number of samples of sequence)($J
disp"(Enter the coeff of the system response*filter function belo!($J
b)input"(Enter the -alue of coeff of numerator)($J
a)input"(Enter the -alue of coeff of denomator)($J
,)8!0!n*0J
stp)ones"0&n$J
imp)10&/eros"0&n*0$2J
P:nit Step Desponse
stpr)filter"b&a&stp$J
subplot"3&0&0$J
x)stem",&stpr$J
set"x&(Mar,er<aceColor(&(red($
title"(:nit Step Desponse($
impr)filter"b&a&imp$J
subplot"3&0&3$J
y)stem",&impr$J
set"y&(Mar,er<aceColor(&(red($
title"(:nit 9npulse Desponse($
4;
Electronics and Communication Department
23SA*?S
0' Dunnin+ for A"/$ )
0 0
0
4 3
3 0

+ +
+
z z
z
CHMMAGD .9GDH.
Enter the number of samples of sequence)38
Enter the coeff of the system response*filter funciton
Enter the -alue of coeff of numerator)10 32
Enter the -alue of coeff of denomator)13 0 42
.-,A23 /-ND@/
4C
Electronics and Communication Department
%. 2unning (or E(&) 8
@ ' 8 &
0
0
0
=

a fr
az
a
C@BBAND /-ND@/
Enter the number of samples of sequence);8
Enter the coeff of the system response*filter funciton
Enter the -alue of coeff of numerator) 8'3
Enter the -alue of coeff of denomator)10 *8'@2
.-,A23 /-ND@/
0 5 10 15 20 25 30 35 40 45 50
0
0.5
1
Unit Step Response
0 5 10 15 20 25 30 35 40 45 50
0
0.05
0.1
0.15
0.2
Unit Inpulse Response
4?
Electronics and Communication Department

Class : 7
th
Sem Subject : Digital Signal Processing
Practical No. 5 Subject Code : 17100
Aim : To compute D<T and 9D<T from direct formulas usin+ user defined functions dft'm
and idft'm'
?heor" :
The D<T "Discrete <ourier Transform$ of sequence x"n$ is +i-en by
0 &'''& 3 & 0 & 8 & $ " $ "
0
8
> 3
= =

N k e n x k !
N
n
N kn j

=
=
0
8
$ "
N
n
kn
N
" n x
#$ere "N ) e
-j%&N
) Tiddle factor'
The 9D<T "9n-erse Discrete <ourier Transform$ is +i-en by
0 &'''& 3 & 0 & 8 & $ " $ "
0
8
> 3
= =

=
N n e k ! n x
N
k
N kn j

=
0
8
$ "
N
k
kn
N
" k !
Bain Program:
P This pro+ram computes D<T of a finite duration sequence'

PThis pro+ram calls user defined functions D<T and 9D<T'

clcJ
clear allJ
G) input"(Go' of samples of x"n$ !($J
for n)0!G
x"0&n$) input"1(x"(& num3str"n$&($ ! (2$J
endJ
Pdisp"x$J
x0)num3str"x$J
disp"1(9nput Sequence ! (&x02$J
ticJ P start stop atch timer'
%, ) dft"x&G$J P Computes D<T Sequence %,'
t0)tocJ P End stop atch timer'
disp"1(D<T Sequence ! (& num3str"%,$2$J
xn) idft"%,&G$J P Computes D<T Sequence %,'
xn)real"xn$J
disp"1(9D<T Sequence ! (& num3str"xn$2$J
disp"(Total computation time for D<T in sec )($J
disp"t0$J
4@
Electronics and Communication Department
.unction to calculate D.? (d(t.m):
function 1%,2 ) dft"xn&G$
P Computes Discrete <ourier Transform
P ***********************************
P Syntax is as follos'
P 1%,2 ) dft"xn&G$
P .here&
P %, ) D<T coeff' array o-er 8 I) , I) G*0
P xn ) G*point finite*duration sequence
P G ) Len+th of D<T

P
if nar+in Z) 3
error"(Go' of ar+uments must be 3($J
end
if len+th"xn$YG
error"(Len+th of sequence must be less than or equal to G($J
else
n/pad ) G*len+th"xn$J
xn0 ) 1xn&/eros"0&n/pad$2J
n ) 18!0!G*02J P ro -ector for n
, ) 18!0!G*02J P ro -ecor for ,
.G ) exp"*6737pi>G$J P .n factor
n, ) n(7,J P creates a G by G matrix of n, -alues
.Gn, ) .G '[ n,J P D<T matrix
%, ) xn0 7 .Gn,J P ro -ector for D<T coefficient
end
.unction to calculate -D.? (id(t.m):
function 1xn2 ) idft"%,&G$
P Computes 9n-erse Discrete Transform
P ***********************************
P 1xn2 ) idft"%,&G$
P xn ) G*point sequence o-er 8 I) n I) G*0
P %, ) D<T coeff' array o-er 8 I) , I) G*0
P G ) len+th of D<T
P
n ) 18!0!G*02J P ro -ector for n
, ) 18!0!G*02J P ro -ecor for ,
.G ) exp"*6737pi>G$J P .n factor
n, ) n(7,J P creates a G by G matrix of n, -alues
.Gn, ) .G '[ "*n,$J P 9D<T matrix
xn ) "%, 7 .Gn,$>GJ P ro -ector for 9D<T -alues
Note: The functions should be in the MATLAB path or they should be in the same folder in hich
main pro+ram resides& otherise \function not defined] error messa+e ill be +enerated'
4B
Electronics and Communication Department
2esults o( D.? F -D.?.
Command /indo0 :
Go' of samples of x"n$ !;
x"0$ ! 0
x"3$ ! 0
x"4$ ! *0
x"=$ ! 0
x";$ ! 0
9nput Sequence ! 0 0 *0 0 0
D<T Sequence ! 458i 0'C0@50'0?;Ci *8'C0@84*0'B830i *8'C0@8450'B830i
0'C0@*0'0?;Ci
9D<T Sequence ! 0 0 *0 0 0
Total computation time for D<T in sec )
8'80B@
Conclusion !
=8
Electronics and Communication Department

Class : 7
th
Sem Subject : Digital Signal Processing
Practical No. 6 Subject Code : 17100
P D<T and 9D<T usin+ Matlab functions fft and ifft
P Compute D<T and 9D<T of sequence x"n$) 10 0 *0 0 02& G);
clcJ
clear allJ
G)input"(Go of samples of sequence x"n$!($J
for n)0!G
x"0&n$)input"1(x"(&num3str"n$&($!(2$J
end
disp"(input sequence is!($J
disp"x$J
ticJ PStart stop atch timer'
%,)fft"x&G$J
t0)tocJ PEnd stop atch timer'
disp"(D<T of sequence is!($J
disp"%,$J
%n)ifft"%,&G$J
disp"(9D<T of D<T seq is!($J
disp"%n$J
disp"(Total computation time for D<T usin+ <<T in sec )($J
disp"t0$J
Desults of <<T V 9<<T'
Command .indo !
Go of samples of sequence x"n$!;
x"0$!0
x"3$!0
x"4$!*0
x"=$!0
x";$!0
input sequence is!
0 0 *0 0 0
D<T of sequence is!
Columns 0 throu+h 3
4'8888 0'C0@8 5 0'0?;Ci
Columns 4 throu+h =
=0
Electronics and Communication Department
*8'C0@8 * 0'B830i *8'C0@8 5 0'B830i
Column ;
0'C0@8 * 0'0?;Ci
9D<T of D<T seq is!
0 0 *0 0 0
Total computation time for D<T usin+ <<T in sec )
?'C;=Ce*88;
Conclusion ! Compare the computational time usin+ <<T al+orithm and Direct D<T formula as
follos!
Datio of Computational Time )
3;@'CC@8
88; * ?'C;=Ce
8'80B@
=
Thus& <<T al+orithm is approximately 3C8 times faster than Direct Computation'
=3
Electronics and Communication Department

Class : 7
th
Sem Subject : Digital Signal Processing
Practical No. 10 Subject Code : 17100
PSimple <ilter desi+n usin+ the technique of placin+ poles and /eros at
Pproper locations in /*plane'

PTo plot the frequency response plots of Simple LP<'
PTry folloin+s&
P0$ <or LP<& e place pole near )8 ithin unit circle and /ero at ori+in'
PThe required transfer function is&
PA"/$ ) "0*a$>"0*a/[*0$'
P ) 8'0>"0*8'B/[*0$' a)8'B'
PFain F is selected as "0*a$ to ha-e normali/ed +ain at )8'
P3$ Pole at near )8 and /ero at )pi'
PThe required transfer function is&
PA"/$ ) "0*a$"05/[*0$>3"0*a/[*0$'
P ) "8'0$"05/[*0$>3"0*8'B/[*0$'
P ) "8'8;58'8;/[*0$>"0*8'B/[*0$'
Por ) "8'058'0/[*0$>"3*0'@/[*0$'


P 9n first case& )pi ill not be completely suppressed' here as in
P second case& )pi ill be completely suppressed'

Pfunction used is freq/"b&a$hich is described belo'

clcJ
clear allJ
close allJ Pdeletes all pri-ious fi+ures hose handles are not hidden'
b)input"(Enter numarator polynomial sequence ! ($J
a)input"(Enter denominator polynomial sequence ! ($J
1A&2)freq/"b&a$J Pfrequency response -ector A and the correspondin+
Pfrequency -ector
P A and are column -ectors'
)(J
) 1*fliplr"$&"3!len+th"$$2J P<req' from *pi to pi'
Ama+ ) abs"A$J
Ama+ ) Ama+(J
Ama+)1fliplr"Ama+$&Ama+"3!len+th"Ama+$$2J PAma+ o-er *pi to pi'
Aan+ ) an+le"A$J
Aan+ ) Aan+(J
Aan+)1*fliplr"Aan+$&Aan+"3!len+th"Aan+$$2JP%aan+ o-er *.max to .max'

subplot"4&0&0$J plot">pi&Ama+$J axis"1*0 0 8 02$J
xlabel"(frequency in pi units($J ylabel"(QA"$Q($J title"(Ma+nitude of A"$($J

subplot"4&0&3$J plot">pi&387lo+08"Ama+$$J axis"1*0 0 *088 82$J
=4
Electronics and Communication Department
xlabel"(frequency in pi units($J ylabel"(387lo+"QA"$Q$($J title"(Ma+nitude of A"$in dB($J

subplot"4&0&4$J plot">pi&Aan+>pi$J axis"1*0 0 *0 02$J
xlabel"(frequency in pi units($J ylabel"(Phase of A"$in radians($J title"(An+le of A"$($J
PSimple <ilter desi+n usin+ the technique of placin+ poles and /eros at
Pproper locations in /*plane'
==
Electronics and Communication Department

PTo plot the frequency response plots 'of Simple AP<'
PTry folloin+s&
P0$ <or LP<& e place pole near )pi ithin unit circle and /ero at ori+in'
Pi'e' e required to reflect the pole*/ero locations of A"/$ of LP<'
PThe required transfer function is&
PA"/$ ) "0*a$>"05a/[*0$'
P ) 8'0>"058'B/[*0$' a)8'B'
PFain F is selected as "0*a$ to ha-e normali/ed +ain at )8'
P3$ Pole at near )pi and /ero at )8'
PThe required transfer function is&
PA"/$ ) "0*a$"0*/[*0$>3"05a/[*0$'
P ) "8'0$"0*/[*0$>3"058'B/[*0$'
P ) "8'8;*8'8;/[*0$>"058'B/[*0$'
Por ) "8'0*8'0/[*0$>"350'@/[*0$'


P 9n first case& )pi ill not be completely suppressed' here as in
P second case& )pi ill be completely suppressed'

Pfunction used is freq/"b&a$hich is described belo'

clcJ
clear allJ
close allJ Pdeletes all pri-ious fi+ures hose handles are not hidden'
b)input"(Enter numarator polynomial sequence ! ($J
a)input"(Enter denominator polynomial sequence ! ($J
1A&2)freq/"b&a$J Pfrequency response -ector A and the correspondin+
Pfrequency -ector
P A and are column -ectors'
)(J
) 1*fliplr"$&"3!len+th"$$2J P<req' from *pi to pi'
Ama+ ) abs"A$J
Ama+ ) Ama+(J
Ama+)1fliplr"Ama+$&Ama+"3!len+th"Ama+$$2J PAma+ o-er *pi to pi'
Aan+ ) an+le"A$J
Aan+ ) Aan+(J
Aan+)1*fliplr"Aan+$&Aan+"3!len+th"Aan+$$2JP%aan+ o-er *.max to .max'

subplot"4&0&0$J plot">pi&Ama+$J axis"1*0 0 min"8&min"Ama+$$ max"Ama+$2$J
xlabel"(frequency in pi units($J ylabel"(QA"$Q($J title"(Ma+nitude of A"$($J

subplot"4&0&3$J plot">pi&387lo+08"Ama+$$J axis"1*0 0 *088 82$J
xlabel"(frequency in pi units($J ylabel"(387lo+"QA"$Q$($J title"(Ma+nitude of A"$in dB($J

subplot"4&0&4$J plot">pi&Aan+>pi$J axis"1*0 0 *0 02$J
xlabel"(frequency in pi units($J ylabel"(Phase of A"$in radians($J title"(An+le of A"$($J
=;
Electronics and Communication Department
=C

Você também pode gostar