Experimet 1 Furier Series & Furier Trasfrms MATLAB Simulati Objectives Furier aalysis plays a imprtat rle i cmmuicati thery. The mai bjectives f this experimet are: 1) T gai a gd uderstadig ad practice with Furier series ad Furier Trasfrm techiques, ad their applicatis i cmmuicati thery. 2) Lear hw t implemet Furier aalysis techiques usig MATLAB. Pre-Lab Wrk Yu are expected t d the fllwig tasks i preparati fr this lab: MATLAB is a user-friedly, widely used sftware fr umerical cmputatis (as yu leared i EE207). Yu shuld have a quick review f the basic cmmads ad sytax fr this sftware. The fllwig exercises will als help i this regard. Nte: it is imprtat t remember that Matlab is vectr-rieted. That is, yu are maily dealig with vectrs (r matrices). 1) Csider the fllwig cde: Y3+5j a. Hw d yu get MATLAB t cmpute the magitude f the cmplex umber Y? b. Hw d yu get MATLAB t cmpute the phase f the cmplex umber Y? 2) Vectr maipulatis are very easy t d I MATLAB. Csider the fllwig: xx[es(1,4), [2:2:11], zers(1,3)] xx(3:7) legth(xx) xx(2:2:legth(xx)) Explai the result btaied frm the last three lies f this cde. Nw, the vectr xx ctais 12 elemets. Observe the result f the fllwig assigmet: xx(3,7)pi*(1:5)
Nw, write a statemet that will replace the dd-idexed elemets f xx with the cstat 77 (i.e., xx(1), xx(3), etc). Use vectr idexig ad vectr replacemet. 3) Csider the fllwig file, amed example.m: f200; tt[0:1/(20*f):1]; zexp(j*2*pi*f*t; subplt(211) plt(real(z)) title( REAL PART OF z ) subplt(212) plt(imag(z)) title( IMAGINARY OF z ) a. Hw d yu execute the file frm the MATLAB prmpt? b. Suppse the file ame was example.cat. Wuld it ru? Hw shuld yu chage it t make it wrk i MATLAB? c. Assumig that the M-file rus, what d yu expect the plts t lk like? If yu re t sure, type i the cde ad ru it. Itrducti Recall frm what yu leared i EE207 that the iput-utput relatiship f a liear timeivariat (LTI) system is give by the cvluti f the iput sigal with the impulse respse f the LTI system. Recall als that cmputig the impulse respse f LTI systems whe the iput is a expetial fucti is particularly easy. Therefre, it is atural i liear system aalysis t lk fr methds f expadig sigals as the sum f cmplex expetials. Furier series ad Furier trasfrms are mathematical techiques that d exactly that!, i.e., they are used fr expadig sigals i terms f cmplex expetials. Furier Series: A Furier series is the rthgal expasi f peridic sigals with perid T whe the j2πt / T sigal set {e } is emplyed as the basis fr the expasi. With this basis, ay give peridic sigal x( with perid T ca be expressed as: where the x( x e j2πt / T x s are called the Furier series cefficiets f the sigal x (. These cefficiets are give by: x T 1 T j2 π t / T 0 x( e dt 3
This type f Furier series is called the expetial Furier series. The frequecy f 1/ is called the fudametal frequecy f the peridic sigal. The th harmic is T give by the frequecy f f. If x( is a real-valued peridic sigal, the the cjugate symmetry prperty is satisfied. This basically states that x * x, where * detes the cmplex cjugate. That is, e ca cmpute the egative cefficiets by ly takig the cmplex cjugate f the psitive cefficiets. Based this result, it is bvius t see that: x x x x Furier Trasfrms: The Furier trasfrm is a extesi f the Furier series t arbitrary sigals. As yu have see i class, the Furier Trasfrm f a sigal x (, deted by X ( f ), is defied by: X ( f ) 2πft x( e dt O the ther had, the iverse Furier Trasfrm is give by: If x( is a real sigal, the X ( f ) 2πft x( X ( f ) e df satisfies the fllwig cjugate symmetry prperty: X ( f ) X * ( f ) I ther wrds, the magitude spectrum is eve while the phase spectrum is dd. There are may prperties satisfied by the Furier Trasfrm. These iclude Liearity, Duality, Scalig, Time Shift, Mdulati, Differetiati, Itegrati, Cvluti, ad Parserval s relati. Lab Wrk Part A: Furier Series 1) I MATLAB, g t the cmmad widw ad type Furier_series_dem.m. This will brig up a Graphical User Iterface (GUI) that ca be used t test ad demstrate may ccepts ad prperties f the Furier series expasi. 4
Try differet types f fuctis, startig with the square wave, fully rectified sie, sawtth, etc. Ru differet examples while chagig the fudametal frequecy ad umber f harmics i the FS expasi. Reprt yur bservatis. I particular, explai why the Furier series fr the square ad sawtth waves require may mre harmics tha the rectified sie waves i rder t get a clse match betwee the FS ad the rigial fucti? Csider the plts fr amplitude ad phase spectra. State what ca f symmetry is preset i each type f spectrum, ad why? The plts als idicate the presece f FS terms with egative frequecies! What s the iterpretati f that? Are there really egative frequecies? Explai. 2) Nw, csider a peridic sigal x(. Cmpute ad plt the discrete magitude ad phase t / 2 spectra f this sigal give by x( e where t [ 0, π ]. Fr this, yu eed t use the Fast Furier Trasfrm (FFT) fucti i MATLAB (refer t the tes belw fr mre details). Fr the expasi f the sigal x(, the umber f harmics N t be used shuld be 32, the perid T is π, ad the step size is t s T / N. The utput shuld be i tw figure widws. The first widw shuld ctai x( while the secd widw shuld ctai bth the magitude ad phase spectra versus a vectr f harmics idices (fr example, ). Yu als eed t iclude labels ad titles i all plts. What ca yu bserve frm these plts? Ntes: I MATLAB, Furier series cmputatis are perfrmed umerically usig the Discrete Furier Trasfrm (DFT), which i tur is implemeted umerically usig a efficiet algrithm kw as the Fast Furier Trasfrm (FFT). Refer t the textbk (Sect.2.10 & 3.9) fr mre theretical details. Yu shuld als type: help fft at the MATLAB prmpt ad brwse thrugh the lie descripti f the fft fucti. Because f the peculiar way MATLAB implemets the FFT algrithm, the fft MATLAB fucti will prvide yu with the psitive Furier cefficiets icludig the cefficiet lcated at 0 Hz. Yu eed t use the eve amplitude symmetry ad dd phase symmetry prperties f the Furier series fr real sigals (see the itrducti t Furier series f this experime i rder t fid the cefficiets fr egative harmics. As a illustrati, the fllwig cde shws hw t use fft t btai Furier expasi cefficiets. Yu ca study this cde, ad further ehace it t cmplete yur wrk. X fft(x,n)/n; X [cj(x(n:-1:2)), X]; Xmag abs(x); Xagle agle(x); k-n0/2+1:n0/2-1 stem(k, Xmag(N/2+1:legth(X)-N/2)) stem(k,xagle(n/2+1:legth(x)-n/2)) Useful MATLAB Fuctis: exp, fft(x,n), legth( ), cj, abs, agle, stem, figure, xlabel, ylabel, title. 5
Part B: Furier Trasfrm 3) I the MATLAB cmmad widw, type Furier_tras_dem.m t lauch a GUI that will demstrate ad review the basic prperties f the Furier trasfrm. The basic fucti used is a rectagular uit pulse. First, itrduce a certai time delay i the fucti, ad tice what happes t the amplitude spectra. Explai why? Next, itrduce differet scalig factrs ad cmmet what yu are bservig. Nw, itrduce a frequecy shift, which meas that the uit pulse is multiplied by a give sie r csie sigal with sme frequecy (later, we will see this is kw as Amplitude Mdulati). Referrig t the basic prperties f the FT, explai what yu are bservig i the plts. 4) Nw, csider the sigals x ( ) ad x ( ) described as fllws: 1 t 2 t t + 1, 1 t 0 x ( 1, 0 < t 1 1 t, x ( 1, 2 0 t 1 1 < t 2 Plt these sigals ad their relative spectra i MATLAB. What d yu cclude frm the results yu btaied? Are there ay differeces? Yu eed t plt bth time sigals i e figure widw. Similarly, yu eed t plt the magitude ad phase spectra fr bth sigals i e figure widw, i.e, verlappig each ther. Fr the phase, display small values by usig the axis cmmad. Yu als eed t rmalize the magitude ad phase values, ad yu shuld iclude the labels, titles, grid, etc. Assume the x-axis t wrk as a ruler f uits. Each uit ctais 100 pits ad let the startig pit t be at 5 ad the last pit t be at 5. Ntes: Similar t Furier series, Furier trasfrm cmputatis i MATLAB are easily implemeted usig the fft fucti. The fllwig cde illustrates that. Ntice i particular the fucti fftshift is very useful fr presetig the Furier spectrum i a uderstadable frmat. The iteral algrithm used i MATLAB t fid the FFT pits spreads the sigal pits i the frequecy dmai at the edges f the plttig area, ad the fucti fftshift ceters the frequecy plts back arud the rigi. X fft(x); X fftshift(x); Xmag abs(x); Xmag Xmag/max(X1mag);%Nrmalizati Xagle agle(x); Xagle Xagle/max(Xagle); F [-legth(x)/2:(legth(x)/2)-1]*fs/legth(x); plt(f, Xmag), plt(f, Xagle); 6
5) Repeat the abve fr the fllwig sigals, ad reprt yur bservatis&cclusis 1, t 3 x ( 1 1, t 1 x ( 2 6) I the MATLAB directry yu are wrkig i, yu will fid a MAT-file amed Exp1Part4.mat. Yu eed t lad that file as fllws: lad Exp1Part4.mat After yu successfully laded the file, g t the cmmad widw ad type whs ad press Eter. Yu will tice three stred variables fs (samplig frequecy r 1/ts), t (time axis vectr) ad m (speech sigal). These crrespd t a prti f speech recrdig. The ext step is t plt the speech sigal versus the time vectr t. I the same figure widw ad a secd widw pael, display the magitude spectrum f m (call it M). What is the badwidth f the sigal? What ca yu tice i terms f the speech sigal? I rder t play the sigal prperly, make sure that the speakers are tured ad write the fllwig MATLAB statemet: sud(m,fs) 7