digital signal processing lab file

22
7/23/2019 digital signal processing lab file http://slidepdf.com/reader/full/digital-signal-processing-lab-file 1/22 EXPERIMENT -1 AIM: - Write a Matlab code to generate different types of basic Signals. THEORY- A signal as referred to in communication systems , signal processing , and electrical engineering "is a function that conveys informationabout the behavior or attributes of some phenomenon".There are different types of signals like 1.Sine wave -The sine !ave or sinusoid is amathematical curve that describes a smooth repetitive oscillatio n.The signal repeats itself after a period of pi. #ts most basic form as a function of time $ t % is The sine function attains ma&imum value of ' at angles $n(i%pi) and value * at n+pi. 2.Cosine wave - A cosine !ave is a signal !aveform !ith a shape identical to that of asine !ave , e&cept each point on the cosine !ave occurs e&actly ') cycle earlier than the corresponding point on the sine !ave. A cosine !ave and its corresponding sine !ave have the same freuency, but the cosine !ave leads the sine !ave by * degrees of phase . 3.Exponenia! si"na! -A real e&ponential signal is defined as Where both"A" and "σ" are real. /epending on the value of " σ " the signals !ill be different. #f "σ" is positive the signal x(t) is a gro!ing e&ponential and if "σ" is negative then the signal x(t) is a decaying e&ponential. 0or σ 1*, signal x(t) !ill be constant.

Upload: rahul-yadav

Post on 17-Feb-2018

228 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 1/22

EXPERIMENT -1

AIM: - Write a Matlab code to generate different types of basic Signals.

THEORY- A signal as referred to in communication systems, signal processing,and electrical engineering "is a function that conveys information about the behavior or attributesof some phenomenon".There are different types of signals like

1.Sine wave-The sine !ave or sinusoid is amathematical curve that describes a smoothrepetitiveoscillation.The signal repeats itself after a period of pi. #ts most basic form as afunction of time $t % is

The sine function attains ma&imum value of ' at angles $n(i%pi) and value * at n+pi.

2.Cosine wave- A cosine !ave is a signal !aveform !ith a shape identical to that of asine!ave , e&cept each point on the cosine !ave occurs e&actly ') cycle earlier than thecorresponding point on the sine !ave. A cosine !ave and its corresponding sine !ave have thesame fre uency, but the cosine !ave leads the sine !ave by * degrees of phase .

3.Exponen ia! si"na!-A real e&ponential signal is defined as

Where both"A" and "σ" are real. /epending on the value of "σ " the signals !ill be different.#f"σ" is positive the signal x(t) is a gro!ing e&ponential and if"σ" is negative then thesignal x(t) is a decaying e&ponential. 0orσ 1*, signal x(t) !ill be constant.

Page 2: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 2/22

#.I$p%!se si"na!-The /irac delta function or unit impulse or often referred to as the deltafunction, is the function that defines the idea of a unit impulse in continuous-time. #nformally,this function is one that is infinitesimally narro!, infinitely tall, yet integrates to one. 2erhaps thesimplest !ay to visuali3e this as a rectangular pulse from a -/) to a (/) !ith a height of ')/.As !e take the limit of this setup as / approaches0, !e see that the !idth tends to 3ero and theheight tends to infinity as the total area remainsconstant at one.The impulse function is often !ritten as

Page 3: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 3/22

#f the magnitude at * is ' unit then the function is termed as unit impulse function.

&.'ni s ep (%n) ion-The Heavisi*e s ep (%n) ion, or the%ni s ep (%n) ion, usually denoted by H $but sometimesu or θ %, is adiscontinuous function !hose value is 3ero for negativeargument and one for positive argument.

An alternative form of the unit step, as a function of a discrete variablen

+.Ra$p (%n) ion-The ramp function $ % may be defined analytically in several !ays. 2ossibledefinition is

#t has a value * for &4* and a value r$&%1& for positive &. Thus forming a line !ith slope ' for&5*.

CO,E:

a=[-2*pi:pi/12:2*pi];b=[-1:.1:1];c=[-20:1:20];d=[-5:0.05:5];e=[-20:20]i=1;

for m=-20:20 if(m<0) u(i)=0 else u(i)=m e d i=i!1

Page 4: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 4/22

e dp=si (a);"=cos(a);r=e#p(b)s=[$eros(1%20)%o es(1%1)%$eros(1%20)]&=[$eros(1%100)%1%o es(1%100)]subplo&('%2%1)plo&(a%p)#label( # )

label( si (#) )&i&le( i e cur+e )

subplo&('%2%2)plo&(a%")#label( # )

label( cos(#) )&i&le( ,osi e cur+e )subplo&('%2%')plo&(b%r)#label( # )

label( e # )&i&le( #po e &ial fu c&io )subplo&('%2% )s&em(c%s)#label( &ime )

label( del(&) )&i&le( mpulse fu c&io )subplo&('%2%5)plo&(d%&)#label( &ime )

label( u(&) )&i&le( i& s&ep fu c&io )subplo&('%2% )plo&(e%u)#label( &ime )

label( r(&) )&i&le( 3amp fu c&io )

Page 5: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 5/22

O'TP'T:

Page 6: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 6/22

EXPERIMENT-2

AIM- i e a MAT/A0 )o*e o s ow )onvo!% ion o( wo si"na!s an*ve i( is %sin" $%! ip!i)a ion in ( e %en) *o$ain.

THEORY-

#nmathematics and, in particular,functional analysis, convolution isa mathematical operation on t!o functions f and g , producing a third function thatis typically vie!ed as a modified version of one of the original functions, givingthe area overlap bet!een the t!o functions as a function of the amount that one ofthe original functions istranslated.

The convolution of f and g is !ritten f ∗ g , using anasterisk or star. #t is defined asthe integral of the product of the t!o functions after one is reversed and shifted. Assuch, it is a particular kind ofintegral transform

Page 7: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 7/22

0or comple&-valued functions f , g defined on the set 6 of integers, the discrete convolution of f and g is given by

The convolution theorem for z transforms states that for any $real or%

comple&causal signals and , convolution in the time domain is multiplicationin the domain , i.e. ,

or, using operator notation,

!here , and

Page 8: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 8/22

CO,E:clear allclose allclcw=-2*pi:0.1:2*pi;s1=[2 2 3 7];s2=[4 5 6]; t=conv2(s1 s2!;

[" w]=#re$%(s1 1 w!; [p w]=#re$%(s2 1 w!; r=".*p; [& n]=inv#re$%(r w 5 0!; s' plot(2 2 1!ste&(s1!;)la el( n--+ !

,la el( s1 !title( i nal 1 ! s' plot(2 2 2!ste&(s2!;)la el( n--+ !,la el( s2 !title( i nal 2 ! s' plot(2 2 3!ste&(t!;)la el( n--+ !,la el( conv !title( /onvol'tion ! s' plot(2 2 4!;ste&(&!;)la el( n--+ !,la el( !title( nverse trans#or& !

Page 9: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 9/22

O'TP'T:

Page 10: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 10/22

EXPERIMENT-3

Page 11: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 11/22

AIM- i e a MAT/A0 )o*e o p!o e ( e %en) esponse o( an/TI s s e$.

THEORY-

4 e %en) esponse is the uantitative measure of the output spectrum of asystem or device in response to a stimulus, and is used to characteri3e thedynamics of the system. #t is a measure of magnitude and phase of the output as afunction offre uency, in comparison to the input

0re uency response can be effectively sho!n !ith the help of magnitude and phase plots.

7onsider these plots as e&amples:-

4%n) ion %se*:

Page 12: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 12/22

8h,! 9 1 fre 3$ b,a,n% returns the n-point fre uency response vector, h, and thecorresponding angular fre uency vector, !, for the digital filter !ith numerator anddenominator polynomial coefficients stored in b and a, respectively.

0or eg the fre uency response of the filter:$3%1 '( 3-' ( ;3 -

can be calculated by taking b18' ;9 and a18'9

CO,E:-w=-pi:0.1:pi;n'&=[1 2 3];

en=[4 5 6]; [" w]=#re$%(n'& en w!;&a =a s("!;p"ase=an le("!;s' plot(3 1 1!%plane(n'& en!;

s' plot(3 1 2!plot(w pi &a !;)la el( a nit' e --+ !,la el( re$'enc, --+ !title( a nit' e plot !s' plot(3 1 3!plot(w pi p"ase!;)la el( "ase --+ !,la el( re$'enc, --+ !title( "ase plot !

O'TP'T:

Page 13: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 13/22

Page 14: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 14/22

EXPERIMENT-#

AIM- i e a MAT/A0 )o*e o ) e)5 e s a6i!i o( a *is) e e i$es s e$ %sin"S) 7 -Co n S a6i!i Tes .

THEORY-

A polynomial is said to be stable if either

• all its roots lie in theopen left half-plane, or • all its roots lie in theopen unit disk .

The first condition provides stability for $orcontinuous-time% linear systems, andthe second case relates to stability ofdiscrete-time linear systems. A polynomial!ith the first property is called at times a:ur!it3 polynomial and !ith the second property aSchur polynomial.

A system is defined to be <#<= Stable if every bounded input to the system resultsin a bounded output over the time interval . This must hold for all initial times to.So long as !e don>t input infinity to our system, !e !on>t get infinity output.

A signal is bounded if there is a finite value such that the signalmagnitude never exceeds , that is

for discrete-time signals, or

for continuous-time signals.

0or a discrete time ?T# system, the condition for <#<= stability is that theimpulseresponse be absolutely summable, i.e.

Page 15: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 15/22

Sch@r-7ohn Test 7onsider

/efine

/efine reverse polynomial

The Sch@r-7ohn Stability test states that the polynomial Am$3% has all of itsroots inside the unit circle if and only if the reflection coefficients, m , satisfy thecondition B mB4' for all m1', ..... C . The reflection coefficients are found fromthe follo!ing recursion

!here m 1 am$m%

Page 16: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 16/22

CO,E:n=inp't( nter or er o# eno&inator polno&ial !;#or i=1:n 1 a(i!=inp't( !;encoe##=0;coe##=a a(1!;e=1;#la =0;#or i=1:n =#liplr(coe##!; isp(coe##!

isp( ! 8= (e!;

i# (8+1998 -1! #la =1; rea8 ; en ; te&p=(coe##-8* ! (1-(8 2!!;

#or <=1:n 1; coe##(<!=te&p(<!; en e=e 1;eni# #la ==1 isp( nsta le ,ste& !else i# #la ==0 isp( ta le ,ste& ! enen

Page 17: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 17/22

O'TP'T:

Page 18: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 18/22

EXPERIMENT-&

AIM- i e a MAT/A0 )o*e o s ow ) oss-)o e!a ion an* a% o-)o e!a ion o( si"na!s. A!so s ow e a% o-)o e!a ion an*)onvo!% ion o( %ni s ep (%n) ion

THEORY:#nsignal processing, ) oss-)o e!a ion is a measure of similarity of t!o series as afunction of the lag of one relative to the other. This is also kno!n as a slidingdot product orsliding inner-product. #t is commonly used for searching a long signalfor a shorter, kno!n feature. #t has applications in pattern recognition, single particle analysis, electron tomography, averaging, cryptanalysis,and neurophysiology.

for discrete functions, the cross-correlation is defined as:

C oss-)o e!a ions are useful for determining the time delay bet!een t!o signals,e.g. for determining time delays for the propagation of acoustic signals across amicrophone array

A% o)o e!a ion, also kno!n as se ia! )o e!a ion or ) oss-a% o)o e!a ion,8'9 isthe cross-correlation of a signal !ith itself at different points in time $that is !hat

Page 19: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 19/22

the cross stands for%. #nformally, it is the similarity bet!een observations as afunction of the time lag bet!een them. #t is a mathematical tool for findingrepeating patterns, such as the presence of a periodic signal obscured by noise, oridentifying themissing fundamental fre uency in a signal implied byits harmonic fre uencies. #t is often used insignal processing for analy3ingfunctions or series of values, such astime domain signals.

The discrete autocorrelation at lag for a discrete signal is

Page 20: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 20/22

CO,E:close all

clear allclc)=[1 4 1 3],=[2 5 6 7 1]%=#liplr()!;&=1:7;n=1:>;p=conv2() %!;$=conv2(% ,!;s' plot(2 2 1!ste&(n $!)la el( n --+ !

,la el( ?),(n!--+ !title( /ross-/orrelation !s' plot(2 2 2!ste&(& p!)la el( n --+ !,la el( ?))(n!--+ !title( @'to-/orrelation ! 't=[ones(1 11!]r1=conv2('t 't!;

=0:20;s' plot(2 2 3!ste&( r1!)la el( n --+ !,la el( /onv(n!--+ !title( /onvol'tion[ nit step] !"=-10:10;#t=#liplr('t!r2=conv2('t #t!;s' plot(2 2 4!ste&(" r2!)la el( n --+ !,la el( ?''(n!--+ !title( @'to-/orrelation[ nit tep]] !

Page 21: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 21/22

O'TP'T:

Page 22: digital signal processing lab file

7/23/2019 digital signal processing lab file

http://slidepdf.com/reader/full/digital-signal-processing-lab-file 22/22