Sei sulla pagina 1di 92

Department of Electronics & Comm.

Engineering

LAB MANUAL
SUBJECT: LAB 5 ! D"#"TAL S"#NAL $%&CESS"N#

B.Tec' """ (ear ) * Semester


+Branc': ECE,

TRINITY COLLEGE OF ENGINEERING


Nar-.amoo/-0 1erala0 235 4

TABLE &5 C&NTENTS

E6$.No.
7 4 < :

Topic
5AM"L"A%"SAT"&N 8"T9 MATLAB #ENE%AT"&N &5 BAS"C C&NT"NUES ELEMENTA%( S"#NALS #ENE%AT"&N &5 BAS"C D"SC%ETE ELEMENTA%( S"#NALS #ENE%AT"&N &5 AM 0 5M AND $8M 8A*E #ENE%AT"&N &5 L"NEA% C&N*&LUT"&N US"N# 5UNCT"&N &NL( D5T 8"T9 &UT 5UNCT"&N #ENE%AT"&N &5 C"%CULA% C&N*&LUT"&N US"N# D5T 8"T9 &UT 5UNCT"&N #ENE%AT"&N &5 L"NEA% C&N*&LUT"&N US"N# C"%CULA% C&N*&LUT"&N #ENE%AT"&N &5 D5T #ENE%AT"&N &5 "D5T T& #ENE%ATE A $%&#%AM 5&% E6$LA"N"N# T9E C&NCE$T &5 ALL"AS"N#. T& #ENE%ATE A $%&#%AM 5&% "M$ULSE %ES$&NSE &5 A LT" S(STEM #ENE%AT"&N &5 BUTTE%8&%T9 ""% 5"LTE%

$age No.
: ; 7 7<

7!

47

; ! 3

4: 42 4!

<

77 74

<4 <: 2

7< 7:

#ENE%AT"&N &5 C9EB(S9E* 5"%ST &%DE% 5"LTE% #ENE%AT"&N &5 C9EB(S9E* SEC&ND &%DE% 5"LTE% #ENE%AT"&N &5 5"% 5"LTE% US"N# %ECTAN#ULA% 8"ND&8 BA%TLET 8"ND&8 BLAC1MANN 8"ND&8 1A"SE% 8"ND&8 9ANN"N# 8"ND&8 9AMM"N#B 8"ND&8

<3 ::

75

:3

72 7; 7! 73

#ENE%AT"&N &5 E=U"%"$$LE 5"LTE% #ENE%AT"&N &5 L"NEA% C&N*&LUT"&N US"N# D5T+&*E%LA$ ADD AND &*E%LA$ SA*E MET9&D #ENE%AT"&N &5 5"% 5"LTE% DES"#N US"N# 5%E=UENC( SAM$L"N# MET9&D #ENE%AT"&N &5 >?T%ANS5&%M AND "N*E%SE >? T%ANS5&%M

55 2 2: 22

5AM"L"A%"SAT"&N 8"T9 MATLAB

Aim: To familiari@e Ait' MATLAB softAare0 general f-nctions an/ signal processing toolBoC
f-nctions. T'e name MATLAB stan/s for MATriC LABoratorD pro/-ce/ BD Mat' AorEs "nc.0 USA. "t is a matriC?Base/ poAerf-l softAare pacEage for scientific an/ engineering comp-tation an/ .is-ali@ation. CompleC n-merical proBlems can Be sol.e/ in a fraction of t'e time t'at reF-ire/ Ait' ot'er 'ig' le.el lang-ages. "t pro.i/es an interacti.e en.ironment Ait' '-n/re/s of B-ilt ?in )f-nctions for tec'nical comp-tation0 grap'ics an/ animation. "n a//ition to B-ilt?in?f-nctions0 -ser can create 'is oAn f-nctions. MATLAB offers se.eral optional toolBoCes0 s-c' as signal processing0 control sDstems0 ne-ral netAorEs etc. "t is comman/ /ri.en softAare an/ 'as online 'elp facilitD. MATLAB 'as t'ree Basic Ain/oAs normallDG comman/ Ain/oA0 grap'ics Ain/oA an/ e/it Ain/oA. Comman/ Ain/oA is c'aracteri@e/ BD t'e prompt HIIJ.All comman/s an/ t'e rea/D to r-n program filename can Be tDpe/ 'ere. #rap'ic Ain/oA gi.es t'e /isplaD of t'e fig-res as t'e res-lt of t'e program. E/it Ain/oA is to create program files Ait' an eCtension .m.

Some important comman/s in MATLAB


9elp 9elp comman/ name Demo 8'o 8'os Clear Clear C0D0@ =-it List topics on A'ic' 'elp is a.ailaBle $ro.i/es 'elp on t'e topic selecte/ r-ns t'e /emo program Lists .ariaBles c-rrentlD in t'e AorEspace Lists .ariaBles c-rrentlD in t'e AorEspace Ait' t'eir si@e clears t'e AorEspace0 all t'e .ariaBles are remo.e/ Clears onlD .ariaBles C0D0@ =-its MATLAB

Some of t'e freF-entlD -se/ B-ilt?in?f-nctions in Signal $rocessing ToolBoC


filter+B.a.C, fft +C, ifft +C, con. +a0B, /econ.+B0a, SDntaC of t'is f-nction is ( K filter+B.a.C, "t filters t'e /ata in .ector C Ait' t'e filter /escriBe/ BD .ectors a an/ B to create t'e filtere/ /ata D. "t is t'e D5T of .ector C "t is t'e D5T of .ector C SDntaC of t'is f-nction is C K con. +a0B, "t con.ol.es .ectors a an/ B. T'e res-lting .ector is of Lengt'0 Lengt' +a, L Lengt' +B,?7 SDntaC of t'is f-nction is MF0rN K /econ.+B0a, "t /econ.ol.es .ector F an/ t'e remain/er in .ector r s-c' t'at B K con.+a0F,Lr /esigns an Nt' or/er loApass /igital B-tterAort' filter an/ ret-rns t'e filter coefficients in lengt' NL7 .ectors B +n-merator, an/ a +/enominator,. T'e coefficients are liste/ in /escen/ing poAers of @. T'e c-toff freF-encD 8n m-st Be . O 8n O 7. 0 Ait' 7. correspon/ing to 'alf t'e sample rate. ret-rns t'e or/er N of t'e loAest or/er /igital B-tterAort' filter t'at loses no more t'an %p /B in t'e passBan/ an/ 'as at least %s /B of atten-ation in t'e stopBan/. 8p an/ 8s are t'e passBan/ an/ stopBan/ e/ge freF-encies0 Normali@e/ from to 70 +A'ere 7 correspon/s to pi ra/Psec, /esigns an Nt' or/er loApass /igital C'eBDs'e. filter Ait' % /eciBels of peaE?to?peaE ripple in t'e passBan/. C9EB(7 ret-rns t'e filter coefficients in lengt' NL7 .ectors B +n-merator, an/ A +/enominator,. T'e c-toff freF-encD 8n m-st Be . O 8n O 7. 0 Ait' 7. correspon/ing to 'alf t'e sample rate. /esigns a 'ig'pass filter.

B-tter+N08n,

B-ttor/+8p0 8s0 %p0 %s,

C'eBD7+N0%08n,

C'eBD7+N0%08n0Q'ig'Q,

C'eB7or/+8p0 8s0 %p0 %s, ret-rns t'e or/er N of t'e loAest or/er /igital C'eBDs'e. TDpe " filter t'at loses no more t'an %p /B in t'e passBan/ an/ 'as at least %s /B of atten-ation in t'e stopBan/. 8p an/ 8s are t'e passBan/ an/ stopBan/ e/ge freF-encies0 normali@e/ from to 7 +A'ere 7 correspon/s to pi ra/iansPsample, c'eBD4+N0%08n, /esigns an Nt' or/er loApass /igital C'eBDs'e. filter Ait' t'e stopBan/ ripple % /eciBels /oAn an/stopBan/ e/ge freF-encD 8n. C9EB(4 ret-rns t'e filter coefficients in lengt' NL7 .ectors B +n-merator, an/ A . T'e c-toff freF-encD 8n m-st Be . O 8n O 7. 0 5

Ait' 7. correspon/ing to 'alf t'e sample rate. c'eB4or/+8p0 8s0 %p0 %s, ret-rns t'e or/er N of t'e loAest or/er /igital C'eBDs'e. TDpe "" filter t'at loses no more t'an %p /B in t'e passBan/ an/ 'as at least %s /B of atten-ation in t'e stopBan/. 8p an/ 8s are t'e passBan/ an/ stopBan/ e/ge freF-encies. aBs+C, angle+9, freF@+B0a0N, "t gi.es t'e aBsol-te .al-e of t'e elements of C. 8'en C is compleC0 aBs+C, is t'e compleC mo/-l-s +magnit-/e, of t'e elements of C. "t ret-rns t'e p'ase angles of a matriC Ait' compleC elements in ra/ians. SDntaC of t'is f-nction is M'0AN K freF@+B0a0N, ret-rns t'e Npoint freF-encD .ector A in ra/ians an/ t'e N?point compleC freF-encD response .ector ' of t'e filter BPa. "t plots t'e /ata seF-ence D aa stems from t'e C aCis terminate/ Ait' circles for t'e /ata .al-e. "t plots t'e /ata seF-ence D at t'e .al-es specifie/ in C. "t plots .ector D .ers-s .ector C. "f C or D is a matriC0 t'en t'e .ector is plotte/ .ers-s t'e roAs or col-mns of t'e matriC0 A'ic'e.er line -p. "t a//s teCt at t'e top of t'e c-rrent aCis. "t a//s teCt Besi/e t'e C?aCis on t'e c-rrent aCis. "t a//s teCt Besi/e t'e D?aCis on t'e c-rrent aCis

stem+D, stem+C0D, plot+C0D, title+HteCtJ, ClaBel+HteCtJ, DlaBel+HteCtJ,

#ENE%AT"&N &5 BAS"C C&NT"NUES S"#NALS ECperiment No: ? 7 A"M: ? To write a MATLAB program to common continues time signals

$%&CEDU%E:? Open MATLAB Open new M-file Type t e program !a"e in current #irectory $ompile an# %un t e program for t e output see comman# win#ow& 'igure win#ow

AL#&%"T9M:? (et t e amplitu#e an# fre)uency of t e signal *se +sin,- ,cos -,s)uare, matla. .uilt in functions *sing +plot, function plot t e signal

MATLAB C&DE:? clc/ clear all/ close all/ t0121311424/ f0input567nter t e "alue of fre)uency68/ a0input567nter t e "alue of amplitu#e68/ su.plot53-3-48/ y0a9sin529pi9f9t8/ plot5t-y-8/ :la.el56time68/ yla.el56amplitu#e68/ title56sine wa"e68 gri# on/ su.plot53-3-28/ ;0a9cos529pi9f9t8/ plot5t-;8/ :la.el56time68/ yla.el56amplitu#e68/ title56cosine wa"e68 <

gri# on/ su.plot53-3-38/ s0a9s)uare529pi9f9t8/ plot5t-s8/ :la.el56time68/ yla.el56amplitu#e68/ title56s)uare wa"e68 gri# on/ su.plot53-3-48/ plot5t-t8/ :la.el56time68/ yla.el56amplitu#e68/ title56ramp wa"e68 gri# on/ su.plot53-3-58/ plot5t-a-6r68/ :la.el56time68/ yla.el56amplitu#e68/ title56unit step wa"e68 gri# on/
x=a*exp(-t); subplot(3,3,6); plot(t,x); xlabel('Time'); ylabel('Amplitude'); title('Exponentially Decayin "id on;

!i nal');

5"#U%E:?

SAM$LE "N$UT:? 7nter t e "alue of fre)uency2 7nter t e "alue of amplitu#e4 %ESULTS2 - T us t e generation of continues time signals using matla. was "erifie#

>

#ENE%AT"&N &5 BAS"C D"SC%ETE S"#NALS ECperiment No: ? 4 A"M: ? To write a MATLAB program to common #iscrete time signals

$%&CEDU%E:? Open MATLAB Open new M-file Type t e program !a"e in current #irectory $ompile an# %un t e program for t e output see comman# win#ow& 'igure win#ow

AL#&%"T9M:? (et t e amplitu#e an# fre)uency of t e signal *se +sin,- ,cos -,s)uare, matla. .uilt in functions *sing +stem, function plot t e signal

MATLAB C&DE:? clc/ clear all/ close all/ n0124251/ f0input567nter t e "alue of fre)uency68/ a0input567nter t e "alue of amplitu#e68/ ?0input567nter t e lengt of unit step68/ su.plot53-3-48/ y0a9sin529pi9f9n8/ stem5n-y-6r68/ :la.el56time68/ yla.el56amplitu#e68/ title56sine wa"e68 gri# on/ su.plot53-3-28/ ;0a9cos529pi9f9n8/ stem5n-;8/ :la.el56time68/ yla.el56amplitu#e68/ title56cosine wa"e68 41

gri# on/ su.plot53-3-38/ s0a9s)uare529pi9f9n8/ stem5n-s8/ :la.el56time68/ yla.el56amplitu#e68/ title56s)uare wa"e68 gri# on/ su.plot53-3-48/ stem5n-n8/ :la.el56time68/ yla.el56amplitu#e68/ title56ramp wa"e68 gri# on/ :012?-4/ #0ones54-?8/ su.plot53-3-58/ stem5:-#-6r68/ :la.el56time68/ yla.el56amplitu#e68/ title56unit step wa"e68 gri# on/ :0a9e:p5-t8/ su.plot53-3-68/ stem5t-:8/ :la.el56Time68/ yla.el56Amplitu#e68/ title567:ponentially @ecaying !ignal68/ gri# on/ 5"#U%E:?

SAM$LE "N$UT:? 44

7nter t e "alue of fre)uency 1313 7nter t e "alue of amplitu#e 4 7nter t e lengt of unit step >

%ESULTS: ? T us t e generation of #iscrete time signals using matla. was "erifie#3

42

#ENE%AT"&N &5 AM0 5M AND $8M 8A*E ECperiment No: ? < A"M: ? To write MATLAB program to generating AM- 'M an# ABM wa"e $%&CEDU%E:? Open MATLAB Open new M-file Type t e program !a"e in current #irectory $ompile an# %un t e program for t e output see comman# win#ow& 'igure win#ow

AL#&%"T9M:? (et t e amplitu#e an# fre)uency of t e signal *se +sin, matla. .uilt in functions *sing +plot, function plot t e signal +a, AM 8A*E MATLAB C&DE:? clc/ clear all/ close all/ t0121311424/ set51-6#efaultlinelinewi#t 6-28/ A05/ fm0input56Message fre)uency068/ fc0input56$arrier fre)uency068/ mi0input56Mo#ulation Cn#e:068/ !m0A9sin529pi9fm9t8/ su.plot53-4-48/ plot5t-!m8/ :la.el56Time68/ yla.el56Amplitu#e68/ title56Message !ignal68/ gri# on/ !c0A9sin529pi9fc9t8/ 43

su.plot53-4-28/ plot5t-!c8/ :la.el56Time68/ yla.el56Amplitu#e68/ title56$arrier !ignal68/ gri# on/ !fm05ADmi9!m839sin529pi9fc9t8/ su.plot53-4-38/ plot5t-!fm8/ :la.el56Time68/ yla.el56Amplitu#e68/ title56AM !ignal68/ gri# on/ 5"#U%E:?

SAM$LE "N$UT:? 7nter t e "alue of message fre)uency 41 7nter t e "alue of carrier fre)uency 411 7nter t e "alue of mo#ulation in#e: 135

44

+B,5M 8A*E MATLAB C&DE:? clc/ clear all/ close all/ fm0input56Message 're)uency068/ fc0input56$arrier 're)uency068/ mi0input56Mo#ulation Cn#e:068/ t0121311142134/ m0sin529pi9fm9t8/ su.plot53-4-48/ plot5t-m8/ :la.el56Time68/ yla.el56Amplitu#e68/ title56Message !ignal68/ gri# on/ c0sin529pi9fc9t8/ su.plot53-4-28/ plot5t-c8/ :la.el56Time68/ yla.el56Amplitu#e68/ title56$arrier !ignal68/ gri# on/ y0sin529pi9fc9tD5mi39sin529pi9fm9t888/ su.plot53-4-38/ plot5t-y8/ :la.el56Time68/ yla.el56Amplitu#e68/ title56'M !ignal68/ gri# on/

5"#U%E:? 45

SAM$LE "N$UT:? 7nter t e "alue of message fre)uency 25 7nter t e "alue of carrier fre)uency 411 7nter t e "alue of mo#ulation in#e: 41 +c, $8M 8A*E MATLAB C&DE:? clc/ clear all/ close all/ '20input56Message fre)uency068/ '40input56$arrier !awtoot fre)uency068/ A05/ t0121311424/ c0A39sawtoot 529pi9'49t8/ su.plot53-4-48/ plot5t-c8/ :la.el56time68/ yla.el56Amplitu#e68/ title56$arrier sawtoot wa"e68/ gri# on/ m013<59A39sin529pi9'29t8/ su.plot53-4-28/ plot5t-m8/ 46

:la.el56Time68/ yla.el56Amplitu#e68/ title56Message !ignal68/ gri# on/ n0lengt 5c8/ for i042n if 5m5i8E0c5i88 pwm5i804/ else pwm5i801/ en# en# su.plot53-4-38/ plot5t-pwm8/ :la.el56Time68/ yla.el56Amplitu#e68/ title56plot of ABM68/ a:is5F1 4 1 2G8/ gri# on/ 5"#U%E:?

SAM$LE "N$UT:? Message fre)uency04 $arrier !aw toot fre)uency041 %ESULTS2 - T us t e program for 'M- AM an# ABM is written using MATLAB an# "erifie#3 #ENE%AT"&N &5 L"NEA% C&N*&LUT"&N US"N# 5UNCT"&N &NL(0 D5T 4<

AND 8"T9 &UT 5UNCT"&N ECperiment No: ? : A"M: ? TO write a MATLAB program to compute linear con"olution of two gi"en se)uences $%&CEDU%E:? Open MATLAB Open new M-file Type t e program !a"e in current #irectory $ompile an# %un t e program 'or t e output see comman# win#ow& 'igure win#ow AL#&%"T9M:? %ea# t e input se)uence :FnG -an# plot %ea# t e impulse se)uence FnG - an# plot *se t e matla. function +con",or #ft or loop $on"ol"e t e two se)uence an# plot t e result

a, Linear con.ol-tion -sing f-nction


MATLAB C&DE:? clc/ :0input567nter t e se)uence 4268/ 0input567nter t e se)uence 2268/ y0con"5:- 8/ su.plot53-4-48/ stem5:8/ yla.el56Amplitu#e-E68/ :la.el56?68/ su.plot53-4-28/ stem5 8/ yla.el56Amplitu#e-E68/ :la.el56?68/ su.plot53-4-38/ stem5y8/ yla.el56Amplitu#e-E68/ :la.el56?68/

B,Linear con.ol-tion -sing D5T


4=

MATLAB C&DE:? clc/ n40input56enter t e lengt of se)uence68/ :0input567nter t e se)uence 4268/ n20input56enter t e lengt of se)uence68/ 0input567nter t e se)uence 2268/ :0F:-;eros54-n2-48G/ 0F -;eros54-n4-48G/ H0fft5:8/ I0fft5 8/ J0H39I/ y0ifft5J8/ su.plot53448/ stem5:8/ su.plot53428/ stem5 8/ title56using @'T68/ su.plot53438/ stem5y8

c,Linear con.ol-tion Ait'o-t -sing 5-nction


MATLAB C&DE:? close all clear all :0input567nter :2 68 0input567nter 2 68 m0lengt 5:8/ n0lengt 5 8/ H0F:-;eros54-n8G/ I0F -;eros54-m8G/ for i042nDm-4 J5i801/ for K042m if5i-KD4E18 J5i80J5i8DH5K89I5i-KD48/ else en# en# en# J stem5J8/ yla.el56JFnG68/ 4>

:la.el56-----En68/ title56$on"olution of Two !ignals wit out con" function68/ 5"#U%E:

SAM$LE "N$UT:? 7nter t e co-efficient of :5n80F4 2 3G 7nter t e co-efficient of 5n80F4 4 4G

%ESULTS: ? T us t e program for linear con"olution is written using MATLAB an# "erifie#. y0 4 3 6 5 3

21

#ENE%AT"&N &5 C"%CULA% C&N*&LUT"&N US"N# D5T AND 8"T9 &UT 5UNCT"&N ECperiment No: ? 5 A"M: ? TO write a MATLAB program to compute circular con"olution of two gi"en se)uences $%&CEDU%E:? Open MATLAB Open new M-file Type t e program !a"e in current #irectory $ompile an# %un t e program 'or t e output see comman# win#ow& 'igure win#ow AL#&%"T9M:? %ea# t e input se)uence :4FnG- an# plot %ea# t e input se)uence :2FnG- an# plot *se t e user #efine# matla. function +crconc, con"ol"e t e two se)uences an# plot t e result

a,Circ-lar con.ol-tion -sing D5T


MATLAB C&DE:? clc/ n40input56enter t e lengt of se)uence68/ :0input567nter t e se)uence 4268/ 0input567nter t e se)uence 2268/ H0fft5:8/ I0fft5 8/ J0H39I/ y0ifft5J8/ su.plot53448/ stem5:8/ title56se)uence468 su.plot53428/ stem5 8/ title56se)uence268/ su.plot53438/ stem5y8/ title56using #ft68/ 24

B,Circ-lar con.ol-tion Ait'o-t -sing 5-nction


MATLAB C&DE:? clc/ :0input567nter t e se)uence 4268/ 0input567nter t e se)uence 2268/ n40lengt 5:8/ n20lengt 5 8/ ?0ma:5n4-n28/ :0F:-;eros54-?-n48G/ 0F -;eros54-?-n28G/ for n012?-4 y5nD4801/ for i012?-4 K0mo#5n-i-?8/ y5nD480y5nD48D:5iD489 5KD48/ en# en# #isplay5y8 su.plot54348/ stem5:8/ title56firstse)uence68/ su.plot54328/ stem5 8/ title56secon# se)uence68/ su.plot54338/ stem5y8/ title56circular con"olution68/ 5"#U%E:

22

SAM$LE "N$UT:? 7nter t e co-efficient of :5n80F4 2 3G 7nter t e co-efficient of 5n80F4 4 4G

%ESULTS: ? T us t e program for circular con"olution is written using MATLAB an# "erifie#3 y06 6 6

#ENE%AT"&N &5 L"NEA% C&N*&LUT"&N US"N# C"%CULA% C&N*&LUT"&N

23

ECperiment No: ? 2 A"M: ? TO write a MATLAB program to compute linear con"olution using circular con"olution3 $%&CEDU%E:? Open MATLAB Open new M-file Type t e program !a"e in current #irectory $ompile an# %un t e program for t e output see comman# win#ow& 'igure win#ow AL#&%"T9M:? %ea# t e input se)uence :4FnG- an# plot %ea# t e input se)uence :2FnG- an# plot *se t e user #efine# matla. functions con"ol"e t e two se)uences an# plot t e result MATLAB C&DE:? clear all/close all/ :40input567nter t e se)uence 42 68/ :20input567nter t e se)uence 22 68/ su.plot53448/ stem5:48/ title56Cnput se)uence468/ su.plot53428/ stem5:28/ title56Cnput se)uence268/ ?40numel5:48/ ?20numel5:28/ :40F:4 ;eros54-?2-48G/ :20F:2 ;eros54-?4-48G/ y0ccon"5:4-:28/ su.plot53438/ stem5y8/ title56Lin *sing $ircular68/ 5"#U%E: 24

SAM$LE "N$UT:? 7nter t e co-efficient of :5n80F4 2 3 4G 7nter t e co-efficient of 5n80F4 4 1 1G %ESULTS: ? T us t e program for linear con"olution using circular con"olution is written using MATLAB an# "erifie#3

#ENE%AT"&N &5 D"SC%ETE 5&U%"E% T%ANS5&%M

25

ECperiment No: ? ; A"M: ? TO write a MATLAB program to fin# t e @'T of a se)uence $%&CEDU%E:? Open MATLAB Open new M-file Type t e program !a"e in current #irectory $ompile an# %un t e program 'or t e output see comman# win#ow& 'igure win#ow AL#&%"T9M:? 7nter t e input se)uence :FnG 7nter t e lengt of se)uence *se t e matla. function +fft, Alot t e input an# output se)uence MATLAB C&DE:? clc/ clear all/ close all/ ?0input567nter t e "alue of ?68/ :0input567nter t e input se)uence H5n8268/ t012?-4/ su.plot52-4-48/ stem5t-:8/ :la.el56TCM768/ yla.el56AMALCT*@768/ title56C?A*T !C(?AL68/ gri# on/ y0fft5:-?8 su.plot52-4-28/ stem5t-y8/ :la.el56TCM768/ yla.el56AMALCT*@768/ title56O*TA*T !C(?AL68/ gri# on/

26

5"#U%E:

SAM$LE "N$UT:? 7nter t e "alue of ? 4 7nter t e input se)uence H5n82F4 2 3 4G

%ESULTS: ? T us t e program for #ft is written using MATLAB an# "erifie#3 y 0 4131111 -231111 D 231111i -231111 -231111 - 231111i

"N*E%SE D"SC%ETE 5&U%"E% T%ANS5&%M 2<

ECperiment No: ? ! A"M: ? TO write a MATLAB program to fin# t e C@'T of a se)uence $%&CEDU%E:? Open MATLAB Open new M-file Type t e program !a"e in current #irectory $ompile an# %un t e program 'or t e output see comman# win#ow& 'igure win#ow AL#&%"T9M:? 7nter t e output se)uence yFnG 7nter t e lengt of se)uence-? *se t e matla. function +ifft, Alot t e input an# output se)uence MATLAB C&DE:? clc/ clear all/ close all/ ?0input567nter t e "alue of ?068/ y0input567nter t e se)uence yFnG068/ t012?-4/ su.plot52-4-48/ stem5t-y8/ :la.el56TCM768/ yla.el56AMALCT*@768/ title56C?A*T !C(?AL68/ gri# on/ :0ifft5y-?8 su.plot52-4-28/ stem5t-:8/ :la.el56TCM768/ yla.el56AMALCT*@768/ title56O*TA*T !C(?AL68/ gri# on// 5"#U%E: 2=

SAM$LE "N$UT:? 7nter t e "alue of ?04 7nter t e se)uence yFnG0F41 -2D2i -2 -2-2iG

%ESULTS: ? T us t e program for i#ft is written using MATLAB an# "erifie#3 : 04 2 3 4

2>

#ENE%ATE A $%&#%AM 5&% E6$LA"N"N# T9E C&NCE$T &5 ALL"AS"N# ECperiment No: ? 3 A"M: ? TO write a MATLAB program to fin# t e concept of aliasing3 $%&CEDU%E:? Open MATLAB Open new M-file Type t e program !a"e in current #irectory $ompile an# %un t e program 'or t e output see comman# win#ow& 'igure win#ow AL#&%"T9M:? (et t e amplitu#e an# fre)uency of t e signal *se +sin, matla. .uilt in functions *sing +plot, function plot t e signal MATLAB C&DE:? clc/ t0-412314241/ T04/ fm04LT/ :0cos529pi9fm9t8/ fs404369fm/ fs2029fm/ fs30=9fm/ n40-42424/ :n40cos529pi9n49fmLfs48/ su.plot53348/ plot5t-:8/ :la.el56time in sec68/ yla.el56:5t868/ title56continous time signal68/ su.plot53328/ stem5n4-:n48/ ol# on/ su.plot53328/ plot5n4-:n48/ :la.el56n68/ yla.el56:5n868/ title56#iscrete signal wit fsMfm68/ 31

n20-52425/ :n20cos529pi9n29fmLfs28/ su.plot53338/ stem5n2-:n28/ ol# on/ su.plot53338/ plot5n2-:n28/ :la.el56n68/ yla.el56:5n868/ title56#iscrete signal wit fs0fm68/ n30-2124221/ :n30cos529pi9n39fmLfs38/ su.plot53348/ stem5n3-:n38/ ol# on/ su.plot53348/ plot5n3-:n38/ :la.el56n68/ yla.el56:5n868/ title56#iscrete signal wit fsEfm68/

5"#U%E:

%ESULTS: ? T us t e program to fin# t e concept of Aliasing is written using MATLAB an# "erifie#3

34

#ENE%ATE A $%&#%AM 5&% "M$ULSE %ES$&NSE &5 A LT" S(STEM ECperiment No: ? 7 A"M2 - TO write a MATLAB program to fin# t e impulse response of a system #efine# .y a #ifference e)uation $%&CEDU%E:? Open MATLAB Open new M-file Type t e program !a"e in current #irectory $ompile an# %un t e program 'or t e output see comman# win#ow& 'igure win#ow AL#&%"T9M:? $reate a matri: a for t e coefficient of yFnG $reate a matri: . for t e coefficient of :FnG (enerate an impulse signal 'in# t e response FnG of t e system #efine# .y a an# . coefficient to t e impulse signal using +filter +comman# MATLAB C&DE:? clc/ clear all/ close all/ ?0input567nter t e re)uire# lengt of impulse response ?068/ n012?-4/ .0input567nter t e co-efficients of :5n8-.068/ a0input567nter t e co0efficients of y5n8-a068/ :0F4-;eros54-?-48G/ y0filter5.-a-:8/ stem5n-y8/ :la.el56time68/ yla.el56amplitu#e68/ title56CMA*L!7 %7!AO?!768/ gri# on/

5"#U%E: 32

SAM$LE "N$UT:? (MnNL .;DMn?7N? .:5DMn?4N? .2DMn?<NK .!CMnN? .::CMn?7NL .<2CMn?4NL .4CMn?<N 7nter t e re)uire# lengt of impulse response ?041 7nter t e co-efficient of : 5n8-.0F13= -1344 1336 1312G 7nter t e co-efficient of y 5n8-a0F4 13< -1345 -136G

%ESULTS: ? T us t e program for impulse response of an LTC system is written using MATLAB an# "erifie#3

#ENE%AT"&N &5 BUTTE%8&%T9 ""% 5"LTE%

33

ECperiment No: ? 77 A"M2 - TO write a MATLAB program to plot magnitu#e response an# p ase response of #igital Butter wort filters3 $%&CEDU%E:? Open MATLAB Open new M-file Type t e program !a"e in current #irectory $ompile an# %un t e program 'or t e output see comman# win#ow& 'igure win#ow AL#&%"T9M:? (et t e pass.an# an# stop.an# ripples (et t e pass.an# an# stop.an# e#ge fre)uencies $alculate t e or#er of t e filter using + .uttor# , function 'in# t e filter coefficients- using +.utter, function @raw t e magnitu#e an# p ase response +i, BUTTE%8&%T9 L&8 $ASS 5"LTE%

MATLAB C&DE:? clc/ clear all/ close all/ rp0input56enter t e pass.an# attenuation268/ rs0input56enter t e stop .an# attenuation268/ wp0input56enter t e pass .an# fre)uency268/ ws0input56enter t e stop .an# fre)uency268/ F?-wnG0.uttor#5wpLpi-wsLpi-rp-rs8/ F.-aG0.utter5?-wn8/ fre);5.-a8

34

5"#U%E:?

SAM$LE "N$UT:? 7nter t e pass.an# attenuation2134 7nter t e stop .an# attenuation231 7nter t e pass .an# fre)uency21329pi 7nter t e stop .an# fre)uency21349pi +ii,BUTTE%8&%T9 9"#9 $ASS 5"LTE% MATLAB C&DE:? clc/ clear all/ close all/ rp0input 567nter t e pass .an# attenuation268/ rs0input 567nter t e stop .an# attenuation268/ wp0input 567nter t e pass .an# fre)uency268/ ws0input 567nter t e stop .an# fre)uency268/ F?-wnG0.uttor#5wpLpi-wsLpi-rp-rs8/ F.-aG0.utter5?-wn-6 ig 68/ fre);5.-a8/

35

5"#U%E:?

SAM$LE "N$UT:? 7nter t e pass .an# attenuation2134 7nter t e stop .an# attenuation231 7nter t e pass .an# fre)uency21369pi 7nter t e stop .an# fre)uency21329pi +iii,BUTTE%8&%T9 BAND $ASS 5"LTE%

MATLAB C&DE:? clc/ clear all/ close all/ rp0input56enter t e pass.an# attenuation268/ rs0input56enter t e stop .an# attenuation268/ wp0input56enter t e pass .an# fre)uency268/ ws0input56enter t e stop .an# fre)uency268/ F?-wnG0.uttor#5wpLpi-wsLpi-rp-rs8/ F.-aG0.utter5?-wn8/ fre);5.-a8/

36

5"#U%E:?

SAM$LE "N$UT:? 7nter t 7nter t 7nter t 7nter t e pass.an# attenuation2132 e stop .an# attenuation221 e pass .an# fre)uency2F1329pi-1349piG e stop .an# fre)uency2 F1349pi- 1359piG +i., BUTTE%8&%T9 BAND ST&$ 5"LTE%

MATLAB C&DE:? clc/ clear all/ close all/ rp0input56enter t e pass.an# attenuation268/ rs0input56enter t e stop .an# attenuation268/ wp0input56enter t e pass .an# fre)uency268/ ws0input56enter t e stop .an# fre)uency268/ F?-wnG0.uttor#5wpLpi-wsLpi-rp-rs8/ 3<

F.-aG0.utter5?-wn-,stop,8/ fre);5.-a8/

5"#U%E:?

SAM$LE "N$UT:? 7nter t 7nter t 7nter t 7nter t e pass.an# attenuation2132 e stop .an# attenuation221 e pass .an# fre)uency2F1349pi-1359piG e stop .an# fre)uency2F1329pi-1349piG

%ESULTS:- T us t e magnitu#e response an# p ase response of @igital Butter wort filters was "erifie#3

3=

#ENE%AT"&N &5 C9EB(S9E* 5"%ST &%DE% 5"LTE%S

ECperiment No: ? 74 A"M: ? TO write MATLAB programs to plot magnitu#e response an# p ase response of #igital $ e.ys e" type-4 Low pass- Iig pass- Ban# pass an# Ban# stop filters3 $%&CEDU%E:? Open MATLAB Open new M-file Type t e program !a"e in current #irectory $ompile an# %un t e program 'or t e output see comman# win#ow& 'igure win#ow AL#&%"T9M:? (et t e pass.an# an# stop.an# ripples (et t e pass.an# an# stop.an# e#ge fre)uencies $alculate t e or#er of t e filter using + c e.4or# , function 'in# t e filter coefficients- using +c e.y4, function @raw t e magnitu#e an# p ase response +i, C9EB(S9E*+T($E?7, L&8 $ASS 5"LTE%

MATLAB C&DE:? clc/ clear all/ close all/ rp0input 567nter t e pass .an# attenuation268/ rs0input 567nter t e stop .an# attenuation268/ wp0input 567nter t e pass .an# fre)uency268/ ws0input 567nter t e stop .an# fre)uency268/ F?-wnG0c e.4or#5wpLpi-wsLpi-rp-rs8/ F.-aG0c e.y45?-rp-wn8/ fre);5.-a8/ 3>

5"#U%E:?

SAM$LE "N$UT:? 7nter t 7nter t 7nter t 7nter t e pass .an# attenuation221 e stop .an# attenuation251 e pass .an# fre)uency21339pi e stop .an# fre)uency21349pi

+ii,

C9EB(S9E*+T($E?7,9"#9 $ASS 5"LTE%

MATLAB C&DE:? clc/ clear all/ close all/ rp0input 567nter t e pass .an# attenuation268/ rs0input 567nter t e stop .an# attenuation268/ wp0input 567nter t e pass .an# fre)uency268/ 41

ws0input 567nter t e stop .an# fre)uency268/ F?-wnG0c e.4or#5wpLpi-wsLpi-rp-rs8/ F.-aG0c e.y45?-rp-wn-6 ig 68/ fre);5.-a8/ 5"#U%E:?

SAM$LE "N$UT:? 7nter t 7nter t 7nter t 7nter t +iii, e pass .an# attenuation221 e stop .an# attenuation251 e pass .an# fre)uency21349pi e stop .an# fre)uency21339pi C9EB(S9E*+T($E?7, BAND $ASS 5"LTE%

MATLAB C&DE:? clc/ clear all/ close all/ rp0input 567nter t e pass .an# attenuation268/ rs0input 567nter t e stop .an# attenuation268/ 44

wp0input 567nter t e pass .an# fre)uency268/ ws0input 567nter t e stop .an# fre)uency268/ F?-wnG0c e.4or#5wpLpi-wsLpi-rp-rs8/ F.-aG0c e.y45?-rp-wn8/ fre);5.-a8/ 5"#U%E:?

SAM$LE "N$UT:? 7nter t 7nter t 7nter t 7nter t e pass .an# attenuation221 e stop .an# attenuation2>= e pass .an# fre)uency2F1339pi-1359piG e stop .an# fre)uency2F1349pi-13=9piG

+i.,

C9EB(S9E*+T($E?7,BAND ST&$ 5"LTE%

MATLAB C&DE:? clc/ clear all/ close all/ rp0input567nter t e pass .an# attenuation268/ rs0input567nter t e stop .an# attenuation268/ 42

wp0input567nter t e pass .an# fre)uency268/ ws0input567nter t e stop .an# fre)uency268/ F?-wnG0c e.4or#5wpLpi-wsLpi-rp-rs8/ F.-aG0c e.y45?-rp-wn-6stop68/ fre);5.-a8/ 5"#U%E:?

SAM$LE "N$UT:? 7nter t 7nter t 7nter t 7nter t e pass .an# attenuation221 e stop .an# attenuation2>= e pass .an# fre)uency2F1349pi-13=9piG e stop .an# fre)uency2F1339pi-1359piG

%ESULTS: ? T us t e Amplitu#e response an# p ase response of c e.ys e" type 4 filters were "erifie#3

43

#ENE%AT"&N &5 C9EB(S9E* SEC&ND &%DE% 5"LTE%S

ECperiment No: ?7< A"M2 - TO write MATLAB programs to plot magnitu#e response an# p ase response of #igital $ e.ys e" type-2 Low pass- Iig pass- Ban# pass an# Ban# stop filters $%&CEDU%E2+ Open MATLAB Open new M-file Type t e program !a"e in current #irectory $ompile an# %un t e program 'or t e output see comman# win#ow& 'igure win#ow AL#&%"T9M:? (et t e pass.an# an# stop.an# ripples (et t e pass.an# an# stop.an# e#ge fre)uencies $alculate t e or#er of t e filter using + c e.2or# , function 'in# t e filter coefficients- using +c e.y2, function @raw t e magnitu#e an# p ase response +i, C9EB(S9E*+T($E?4, L&8 $ASS 5"LTE% MATLAB C&DE:? clc/ clear all/ close all/ rp0input 567nter t e pass .an# attenuation268/ rs0input 567nter t e stop .an# attenuation268/ wp0input 567nter t e pass .an# fre)uency268/ ws0input 567nter t e stop .an# fre)uency268/ F?-wnG0c e.2or#5wpLpi-wsLpi-rp-rs8/ 44

F.-aG0c e.y25?-rp-wn8/ fre);5.-a8/

5"#U%E:-

SAM$LE "N$UT:? 7nter t 7nter t 7nter t 7nter t e pass .an# attenuation221 e stop .an# attenuation2<1 e pass .an# fre)uency21339pi e stop .an# fre)uency21349pi

+ii, C9EB(S9E* +T($E?4, 9"#9 $ASS 5"LTE% MATLAB C&DE:? clc/ clear all/ close all/ rp0input 567nter t e pass .an# attenuation268/ rs0input 567nter t e stop .an# attenuation268/ wp0input 567nter t e pass .an# fre)uency268/ 45

ws0input 567nter t e stop .an# fre)uency268/ F?-wnG0c e.2or#5wpLpi-wsLpi-rp-rs8/ F.-aG0c e.y25?-rp-wn-6 ig 68/ fre);5.-a8 5"#U%E:-

SAM$LE "N$UT:? 7nter t 7nter t 7nter t 7nter t e pass .an# attenuation221 e stop .an# attenuation2<1 e pass .an# fre)uency21349pi e stop .an# fre)uency21339pi

+iii,

C9EB(S9E* +T($E?4, BAND $ASS 5"LTE%

MATLAB C&DE:? clc/ clear all/ close all/ rp0input 567nter t e pass .an# attenuation268/ rs0input 567nter t e stop .an# attenuation268/ wp0input 567nter t e pass .an# fre)uency268/ ws0input 567nter t e stop .an# fre)uency268/ 46

F?-wnG0c e.2or#5wpLpi-wsLpi-rp-rs8/ F.-aG0c e.y25?-rp-wn8/ fre);5.-a8/ 5"#U%E:?

SAM$LE "N$UT:? 7nter t 7nter t 7nter t 7nter t e pass .an# attenuation22 e stop .an# attenuation221 e pass .an# fre)uency2F1339pi-1349piG e stop .an# fre)uency2F1349pi-1359piG

+i.,

C9EB(S9E* +T($E?4, BAND ST&$ 5"LTE%

MATLAB C&DE:? clc/ clear all/ close all/ rp0input567nter t e pass .an# attenuation268/ rs0input567nter t e stop .an# attenuation268/ wp0input567nter t e pass .an# fre)uency268/ ws0input567nter t e stop .an# fre)uency268/ F?-wnG0c e.2or# 5wpLpi-wsLpi-rp-rs8/ 4<

F.-aG0c e.y25?-rp-wn-6stop68/ fre);5.-a8/ 5"#U%E:?

SAM$LE "N$UT:? 7nter t e pass .an# attenuation22 7nter t e stop .an# attenuation221 7nter t e pass .an# fre)uency2F1349pi-1359piG 7nter t e stop .an# fre)uency2F1339pi-1349piG

%ESULTS:- T us t e Amplitu#e response an# p ase response of c e.ys e" type 2 filters were "erifie#3

4=

#ENE%AT"&N &5 5"% 5"LTE% US"N# 8"ND&8S. +%ECTAN#ULA%0 BA%TLET BLAC1MANN0 1A"SE%0 9ANN"N# AND 9AMM"N#B 8"ND&8,

ECperiment No: ? 7: A"M: - TO write a MATLAB program to plot magnitu#e response an# p ase response of #igital 'C% filter using win#ows$%&CEDU%E:? Open MATLAB Open new M-file Type t e program !a"e in current #irectory $ompile an# %un t e program 'or t e output see comman# win#ow& 'igure win#ow AL#&%"T9M:?

(et t e or#er of t e filter (et t e cut off fre)uency *se +fir4 ,N correspon#ing win#ow functions to compute t e filter coefficient @raw t e magnitu#e an# p ase response

MATLAB C&DE:?
clc; clea" all; close all; "p=input('ente" passband "ipple'); "s=input('ente" t#e stopband "ipple'); $p=input('ente" passband $"e%'); $s=input('ente" stopband $"e%'); $=input('ente" samplin $"e% '); &p='*$p($; &s='*$s($; num=-')*lo *)(s%"t("p*"s))-*3; dem=*+,6*($s-$p)($; n=ceil(num(dem); n*=n-*; i$("em(n,').=)) n*=n; n=n-*;

4>

end c=input('ente" you" c#oice o$ &indo& $unction *, "ectan ula" ', ba"tlet 3,/aise" +,blac/man 0,#annin 6,#ammin 1 2n '); i$(c==*) y="ect&in(n*); disp('3ectan ula" &indo& $ilte" "esponse'); end i$ (c==') y=ba"tlett(n*); disp('ba"tlett &indo& $ilte" "esponse'); end i$(c==3) y=/aise"(n*); disp('/aise" &indo& $ilte" "esponse'); end i$(c==+) y=blac/man(n*); disp('blac/mann &indo& $ilte" "esponse'); end i$(c==0) y=#annin (n*); disp('#annin &indo& $ilte" "esponse'); end i$(c==6) y=#ammin (n*); disp('#ammin &indo& $ilte" "esponse'); end 4567 b=$i"*(n,&p,y); 8#,o9=$"e%:(b,*,'06); m=')*lo *)(abs(#)); subplot(',',*);plot(o(pi,m); title('567'); ylabel(';ain in d<--='); xlabel('(a) >o"mali:ed $"e%uency--='); 4?67 b=$i"*(n,&p,'#i #',y); 8#,o9=$"e%:(b,*,'06); m=')*lo *)(abs(#)); subplot(',',');plot(o(pi,m); title('?67'); ylabel(';ain in d<--='); xlabel('(b) >o"mali:ed $"e%uency--='); 4<67 &n=8&p,&s9; b=$i"*(n,&n,y); 8#,o9=$"e%:(b,*,'06); m=')*lo *)(abs(#)); subplot(',',3);plot(o(pi,m); title('<67'); ylabel(';ain in d<--='); xlabel('(b) >o"mali:ed $"e%uency--='); 4<!7 &n=8&p,&s9;

51

b=$i"*(n,&n,'stop',y); 8#,o9=$"e%:(b,*,'06); m=')*lo *)(abs(#)); subplot(',',+);plot(o(pi,m); title('<!7'); ylabel(';ain in d<--='); xlabel('(b) >o"mali:ed $"e%uency--=');

5"#U%ES:? 7, US"N# %ECTAN#ULA% 8"ND&8

4, US"N# BA%TLET 8"ND&8

54

<, US"N# BLAC1MANN 8"ND&8

:, US"N# 1A"SE% 8"ND&8

52

5, US"N# 9ANN"N# 8"ND&8

2, US"N# 9AMM"N# 8"ND&8 53

SAM$LE "N$UTS:? 7nter t 7nter t 7nter t 7nter t 7nter t e "alue of pass .an# ripple21315 e "alue of stop .an# ripple21314 e "alue of pass .an# fre)uency24511 e "alue of stop .an# fre)uency22111 e "alue of sampling fre)uency2>111

%ESULTS: ? T'-s t'e magnit-/e response of 5"% filter -sing all tDpes of Ain/oAs Aas .erifie/.

54

#ENE%AT"&N &5 E=U"%"$$LE 5"LTE%

ECperiment No: ?75 A"M: - To write a MATLAB program to plot magnitu#e response of 7)ui-%ipple filter3 $%&CEDU%E:? Open MATLAB Open new M-file Type t e program !a"e in current #irectory $ompile an# %un t e program 'or t e output see comman# win#ow& 'igure win#ow AL#&%"T9M:?

(et t e or#er of t e filter (et t e cut off fre)uency *se correspon#ing filter functions to compute t e filter coefficient3 @raw t e magnitu#e3 55

7, L&8$ASS E=U" %"$$LE 5"LTE%

MATLAB C&DE:?
clc; close all; clea" all; 7s=*))); 7p=input('@nput t#e pass band $"e%uency 7p= '); 7st=input('@nput t#e stop band $"e%uency 7st= '); Ap=input('@nput t#e pass band attenuation Ap= '); Ast=input('@nput t#e stop band attenuation Ast= '); d = $desi n,lo&pass('7p,7st,Ap,Ast',),', ),'', *, 6)); ?d=desi n(d,'e%ui"ipple'); $Atool(?d);

5"#U%E:?

56

4, 9"#9 $ASS E=U" %"$$LE 5"LTE%


MATLAB C&DE:?
4e%ui"ipple 7@3 $ilte" clc; close all; clea" all; 7s=*))); 7p=input('@nput t#e pass band $"e%uency 7p= '); 7st=input('@nput t#e stop band $"e%uency 7st= '); Ap=input('@nput t#e pass band attenuation Ap= '); Ast=input('@nput t#e stop band attenuation Ast= '); d=$desi n,#i #pass('7st,7p,Ast,Ap',*6)),'))),B),*,B)))); ?d=desi n(d,'e%ui"ipple'); $Atool(?d);

5"#U%E:?

<, BAND $ASS E=U" %"$$LE 5"LTE%


MATLAB C&DE:?

5<

4e%ui"ipple 7@3 $ilte" clc; close all; clea" all; 7s=*))); 7p=input('@nput t#e pass band $"e%uency 7p= '); 7st=input('@nput t#e stop band $"e%uency 7st= '); Ap=input('@nput t#e pass band attenuation Ap= '); Ast=input('@nput t#e stop band attenuation Ast= '); D = $desi n,bandpass('7st*,7p*,7p',7st',Ast*,Ap,Ast'',,,, *6)),'))),'+)),'B)),6),*,B),B)))); ?d = desi n(D,'e%ui"ipple'); $Atool(?d);

5"#U%E:

:, BAND ST&$ E=U" %"$$LE 5"LTE% 5=

MATLAB C&DE:?
4e%ui"ipple 7@3 $ilte" clc; close all; clea" all; 7s=*))); 7p=input('@nput t#e pass band $"e%uency 7p= '); 7st=input('@nput t#e stop band $"e%uency 7st= '); Ap=input('@nput t#e pass band attenuation Ap= '); Ast=input('@nput t#e stop band attenuation Ast= '); D = $desi n,bandstop('7p*,7st*,7st',7p',Ap*,Ast,Ap'',,+,,0,,6,,C,*,B),,0); ?d = desi n(D,'e%ui"ipple'); $Atool(?d);

5"#U%E:

SAM$LE "N$UTS:?
7nter t e pass .an# fre)uency 'p0 4211 7nter t e stop .an# fre)uency 'st0 2111

5>

7nter t e pass .an# attenuation Ap0 315 7nter t e stop .an# attenuation Ast0 314

%ESULTS: ? T'-s t'e magnit-/e response of EF-i?%ipple 5"% filters Aere .erifie/.

#ENE%AT"&N &5 L"NEA% C&N*&LUT"&N US"N# D5T +&*E%LA$ ADD AND &*E%LA$ SA*E MET9&D,

ECperiment No: ? 72
A"M: - TO write a MATLAB program to fin# t e linear con"olution of two se)uence using OO7%LAA A@@
A?@ OO7%LAA !AO7 M7TIO@

$%&CEDU%E:? Open MATLAB Open new M-file Type t e program !a"e in current #irectory $ompile an# %un t e program 'or t e output see comman# win#ow& 'igure win#ow AL#&%"T9M:? 'in# t e lengt of first se)uence :FnG 'in# t e lengt of secon# se)uence FnG 7stimate t e num.er of samples in t e result of linear con"olution

61

Alot input an# output se)uences 7, &*E%LA$ ADD MET9&D MATLAB C&DE:?
clc; clea" all; x = input('Ente" t#e se%uence x(n) = '); # = input('Ente" t#e se%uence #(n) = '); n* = len t#(x); n' = len t#(#); > = n*-n'-*; y = :e"os(*,>); #* = 8# :e"os(*,n'-*)9; n3 = len t#(#*); y = :e"os(*,>-n3-n'); ? = $$t(#*); $o" i = *1n'1n* i$ iD=(n*-n'-*) x* = 8x(i1i-n3-n') :e"os(*,n3-n')9; else x* = 8x(i1n*) :e"os(*,n3-n')9; end x' = $$t(x*); x3 = x',*?; x+ = "ound(i$$t(x3)); i$ (i==*) y(*1n3) = x+(*1n3); else y(i1i-n3-*) = y(i1i-n3-*)-x+(*1n3); end end subplot(3,*,*); stem(x(*1n*)); "id on; title('@nput !e%uence x(n)'); xlabel('Time ---='); ylabel('Amplitude ---='); subplot(3,*,'); stem(#(*1n')); "id on; title('@nput !e%uence #(n)'); xlabel('Time ---='); ylabel('Amplitude ---='); subplot(3,*,3); disp('<loc/ EonAolution Fsin GAe"lap Add Het#od = '); disp(y(*1>)); stem(y(*1>)); "id on; title('<loc/ EonAolution Fsin GAe"lap Add Het#od'); xlabel('Time ---='); ylabel('Amplitude ---=');

5"#U%E: 64

SAM$LE "N$UTS:?
7nter t e se)uence :5n8 0 F4 2 3 4 5 6 < = >G 7nter t e se)uence 5n8 0 F4 4 4G BlocP $on"olution *sing O"erlap A## Met o# 0 4 3 6 > 42 45 4= 24 24 4< 7, &*E%LA$ SA*E MET9&D MATLAB C&DE:?
clc; clea" all; x = input('Ente" t#e se%uence x(n) = '); # = input('Ente" t#e se%uence #(n) = '); n* = len t#(x); n' = len t#(#); > = n*-n'-*; #* = 8# :e"os(*,>-n*)9; n3 = len t#(#*); y = :e"os(*,>); x* = 8:e"os(*,n3-n') x :e"os(*,n3)9; ? = $$t(#*); $o" i = *1n'1> y* = x*(i1i-('*(n3-n'))); y' = $$t(y*); y3 = y',*?;

>

62

y+ = "ound(i$$t(y3)); y(i1(i-n3-n')) = y+(n'1n3); end subplot(3,*,*); stem(x(*1n*)); "id on; title('@nput !e%uence x(n)'); xlabel('Time ---='); ylabel('Amplitude ---='); subplot(3,*,'); stem(#(*1n')); "id on; title('@nput !e%uence #(n)'); xlabel('Time ---='); ylabel('Amplitude ---='); subplot(3,*,3); disp('<loc/ EonAolution Fsin GAe"lap !aAe Het#od = '); disp(y(*1>)); stem(y(*1>)); "id on; title('<loc/ EonAolution Fsin GAe"lap !aAe Het#od'); xlabel('Time ---='); ylabel('Amplitude ---=');

5"#U%E:

SAM$LE "N$UTS:? 7nter t e se)uence :5n8 0 F4 2 3 4 5 6 < = >G 7nter t e se)uence 5n8 0 F4 4 4G 63

BlocP $on"olution *sing O"erlap sa"e Met o# 0 4 3 6 > 42 45

4=

24

24

4<

>

%ESULTS: - T us t e program for linear con"olution using is written using OO7%LAA A@@ A?@ OO7%LAA !AO7 M7TIO@ is written using MATLAB an# "erifie#3

#ENE%AT"&N &5 5"% 5"LTE% DES"#N US"N# 5%E=UENC( SAM$L"N# MET9&D

ECperiment No: ?7; A"M: - TO write a MATLAB program to plot magnitu#e response an# p ase response of #igital 'C% filter using fre)uency sampling met o#3 $%&CEDU%E:? Open MATLAB Open new M-file Type t e program !a"e in current #irectory $ompile an# %un t e program 'or t e output see comman# win#ow& 'igure win#ow AL#&%"T9M:?

(et t e or#er of t e filter (et t e cut off fre)uency use +fir2 ,N correspon#ing functions to compute t e filter coefficient @raw t e magnitu#e an# p ase response 64

MATLAB C&DE:?
clc; clea" all; $ = 8) ),*0 ),*0 ),00 ),00 ),C ),C *9; A = 8),)+ * * * * ),)+ ),)+ ),)+9; b = $i"'(3',$,A); a = *; subplot(*,',*) imp:(b,a) subplot(*,',') $"e%:(b,a)

5"#U%E:

%ESULTS: - T us t e program for 'C% filter using fre)uency sampling met o# is written using MATLAB an# "erifie#3 65

#ENE%AT"&N &5 >?T%ANS5&%M AND "N*E%SE >? T%ANS5&%M

ECperiment No: ? 7! A"M: - To write a MATLAB program to plot Q-T%A?!'O%M A?@ C?O7%!7 Q- T%A?!'O%M of gi"en se)uences3 $%&CEDU%E:? Open MATLAB Open new M-file Type t e program !a"e in current #irectory $ompile an# %un t e program for t e output see comman# win#ow& 'igure win#ow AL#&%"T9M:?

(et t e numerator an# #enominator3 *se t$':p; :p'sos functions to compute3 @raw response3 66

>?T%ANS5&%M
MATLAB C&DE:?
clc; clea" all; num = input('Type in t#e nume"ato" coe$$icients ='); den = input('Type in t#e denominato" coe$$icients ='); 8:,p,/9=t$':p (num,den); m = abs(p); 4 to $ind distance $"om o"i in o$ poles disp('Ie"os a"e at'); disp(:); disp('poles a"e at'); disp(p); disp(' ain constant'); disp(/); disp('3adius o$ poles'); disp(m); sos= :p'sos(:,p,/); disp('!econd o"de" sections'); disp("eal(sos)); :plane(num,den);

5"#U%E:

6<

Qeros are at -436516 -134<4< D 43546>i -134<4< - 43546>i poles are at -431111 -131111 D 431111i -131111 - 431111i gain constant 4 %a#ius of poles 431111 431111 431111 !econ# or#er sections 431111 436516 1 431111 431111 431111 1334>4 234233 431111 131111 SAM$LE "N$UTS:? 7nter t e numerator coefficients 0 F4 2 3 4G 7nter t e #enominator coefficients 0 F4 4 4 4G "N*E%SE >?T%ANS5&%M
MATLAB C&DE:?
clc; clea" all; close all; 5=input('len t# o$ output Aecto"='); num=input('nume"ato" coe$$icient'); den=input('denominato" coe$$icient'); 8y,t9=imp:(num,den,5); disp(y); stem(y,t);

1 431111

5"#U%E:

6=

SAM$LE "N$UTS: Lengt of output "ector 0 44 ?umerator coefficient 0 F4 2G @enominator coefficient 0 F4 34 -342G %ESULTS: - T us t e program for Q T%A?!'O%M an# C?O7%!7 Q T%A?!'O%M are written using MATLAB an# "erifie#3

6>

"NT%&DUCT"&N T& T9E TMS <4 C2;7<

<1

<4

FUNCTIONAL OVERVIEW OF THE TMS 320C6713 DSK

<2

CODE COMPOSER STUDIO


T e $o#e $omposer !tu#io 5$$!8 pro"i#es an integrate# #e"elopment en"ironment 5C@78 to incorporate t e software tools3 $$! inclu#es tools for co#e generation- suc as a $ compiler- an assem.ler- an# a linPer3 Ct as grap ical capa.ilities an# supports real-time #e.ugging3 Ct pro"i#es an easy-to-use software tool to .uil# an# #e.ug programs3 T e $ compiler compiles a $ source program wit e:tension 3c to pro#uce an assem.ly source file wit e:tension3asm3 T e assem.ler assem.les an.asm source file to pro#uce a mac ine language o.Kect file wit e:tension.obj3 T e linPer com.ines o.Kect files an# o.Kect li.raries as input to pro#uce an e:ecuta.le file wit e:tension.out3 T is e:ecuta.le file represents a linPe# common o.Kect file format 5$O''8- popular in *ni:-.ase# systems an# a#opte# .y se"eral maPers of #igital signal processors3 T is e:ecuta.le file can .e loa#e# an# run #irectly on t e $6<43 processor3 To create an application proKect- one can Ra##S t e appropriate files to t e proKect3 $ompilerLlinPer options can rea#ily .e specifie#3 A num.er of #e.ugging features are a"aila.leinclu#ing setting .reaPpoints an# watc ing "aria.les- "iewing memory- registers- an# mi:e# $ an# assem.ly co#e- grap ing results- an# monitoring e:ecution time3 One can step t roug a program in #ifferent ways 5step into- or o"er- or out83 %eal-time analysis can .e performe# using real-time #ata e:c ange 5%T@H8 associate# wit @!ALBCO! 3%T@H allows for #ata e:c ange .etween t e ost an# t e target an# analysis in real time wit out stopping t e target3 Tey statistics an# performance can .e monitore# in real time3 T roug t e Uoint Team Action (roup 5UTA(8- communication wit on-c ip emulation support occurs to control an# monitor program e:ecution3 T e $6<43 @!T .oar# inclu#es a UTA( emulator interface3

<3

<4

<5

<6

<<

<=

<>

=1

=4

=2

=3

=4

=5

=6

=<

==

=>

References
FA.r<2G M3 A.ramowit; an# C3A3 !tegun- e#itors3 Ian#.ooP of Mat ematical 'unctions3 @o"er Au.lications- ?ew JorP ?J- 4><23 FBag>=G !3 Bagc i an# !3T3 Mitra3 ?onuniform @iscrete 'ourier Transform an# Cts !ignal Arocessing Applications3 Tluwer- Boston MA- 4>>=3 FBat=1G M3%3 Bateman an# B3 Liu3 An approac to programma.le $T@ Vlters using coefVcients 1- D4- an# W43 C777 Trans3 on $ircuits an# !ystems- $A!-2<2454456- Uune 4>=13 F$io>4G U3 $iofV3 A Multicarrier Arimer3 A?!C T47434 $ommittee $ontri.ution- Boca %aton 'L- ?o"em.er 4>>43 F$on<1G A3$3 $onstantini#es3 !pectral transformations for #igital Vlters3 Aroc3 C77 5Lon#on8- 44<245=5X45>1- August 4><13 F$ro<5G %373 $roc iere an# A3O3 Oppen eim3 Analysis of linear #igital networPs3 Aroc3 C777- 6225=4X5>5- April 4><53 F(as=5G L3 (as;i3 7:plicit formulas for lattice wa"e #igital Vlters3 C777 Trans3 on $ircuits N !ystems- $A!-3226=X==- Uanuary 4>=53 F(ra<3G A3I3 (ray- Ur3 an# U3 @3 MarPel3 @igital lattice an# la##er Vlter synt esis3 C777 Trans3 on Au#io an# 7lectroacoustics- A*-2424>4X511- @ecem.er 4><33 FIer<3G O3 Ierrmann- L3%3 %a.iner- an# @3!3T3 $ an3 Aractical #esign rules for optimum Vnite impulse response lowpass #igital Vlters3 Bell !ystem Tec 3 U3- 522<6>-<>>4><33 FUac<1G L3B3 UacPson3 On t e interaction of roun#off noise an# #ynamic range in #igital Vlters3 Bell !ystem Tec nical Uournal- 4>245>X4=4- 'e.ruary 4><13 FUac>6G L3B3 UacPson3 @igital 'ilters an# !ignal Arocessing3 Tluwer- Boston MA- t ir# e#ition- 4>>63 FUar==G A3 UarsPe- J3 ?eu"o- an# !3T3 Mitra3 A simple approac to t e #esign of 'C% Vlters wit "aria.le c aracteristics3 !ignal Arocessing- 442343X326- 4>==3

>1

FTai<4G U3'3 Taiser3 ?onrecursi"e #igital Vlter #esign using t e C1-sin win#ow function3 Aroc3 4><4 C777 Cnternational !ymposium on $ircuits an# !ystems- pages 21-23!an 'rancisco $A- April 4><43 FTra>4G T3A3 Trauss- L3 ! ure- an# U3?3 Little3 !ignal Arocessing TOOLBOH for use wit MATLAB3 T e Mat worPs- Cnc3- ?aticP MA- 4>>43 FA.r<2G M3 A.ramowit; an# C3A3 !tegun- e#itors3 Ian#.ooP of Mat ematical 'unctions3 @o"er Au.lications- ?ew JorP ?J- 4><23 FBag>=G !3 Bagc i an# !3T3 Mitra3 ?onuniform @iscrete 'ourier Transform an# Cts !ignal Arocessing Applications3 Tluwer- Boston MA- 4>>=3 FBat=1G M3%3 Bateman an# B3 Liu3 An approac to programma.le $T@ Vlters using coefVcients 1- D4- an# W43 C777 Trans3 on $ircuits an# !ystems- $A!-2<2454456- Uune 4>=13 F$io>4G U3 $iofV3 A Multicarrier Arimer3 A?!C T47434 $ommittee $ontri.ution- Boca %aton 'L- ?o"em.er 4>>43 F$on<1G A3$3 $onstantini#es3 !pectral transformations for #igital Vlters3 Aroc3 C77 5Lon#on8- 44<245=5X45>1- August 4><13 F$ro<5G %373 $roc iere an# A3O3 Oppen eim3 Analysis of linear #igital networPs3 Aroc3 C777- 6225=4X5>5- April 4><53 F(as=5G L3 (as;i3 7:plicit formulas for lattice wa"e #igital Vlters3 C777 Trans3 on $ircuits N !ystems- $A!-3226=X==- Uanuary 4>=53 F(ra<3G A3I3 (ray- Ur3 an# U3 @3 MarPel3 @igital lattice an# la##er Vlter synt esis3 C777 Trans3 on Au#io an# 7lectroacoustics- A*-2424>4X511- @ecem.er 4><33 FIer<3G O3 Ierrmann- L3%3 %a.iner- an# @3!3T3 $ an3 Aractical #esign rules for optimum Vnite impulse response lowpass #igital Vlters3 Bell !ystem Tec 3 U3- 522<6>-<>>4><33 FUac<1G L3B3 UacPson3 On t e interaction of roun#off noise an# #ynamic range in #igital Vlters3 Bell !ystem Tec nical Uournal- 4>245>X4=4- 'e.ruary 4><13 FUac>6G L3B3 UacPson3 @igital 'ilters an# !ignal Arocessing3 Tluwer- Boston MA- t ir# e#ition- 4>>63 >4

FUar==G A3 UarsPe- J3 ?eu"o- an# !3T3 Mitra3 A simple approac to t e #esign of 'C% Vlters wit "aria.le c aracteristics3 !ignal Arocessing- 442343X326- 4>==3 FTai<4G U3'3 Taiser3 ?onrecursi"e #igital Vlter #esign using t e C1-sin win#ow function3 Aroc3 4><4 C777 Cnternational !ymposium on $ircuits an# !ystems- pages 21-23!an 'rancisco $A- April 4><43 FTra>4G T3A3 Trauss- L3 ! ure- an# U3?3 Little3 !ignal Arocessing TOOLBOH for use wit MATLAB3 T e Mat worPs- Cnc3- ?aticP MA- 4>>43

>2

Potrebbero piacerti anche