ECE 350 Malab-Based Projec #3 Due Dae: Nov. 26, 2008 Read he aached Malab uorial ad read he help files abou fucio i, subs, sem, bar, sum, aa2. he wrie a sigle Malab M file o complee he followig ask for he periodic sigal x () depiced i Figure 1. Submi your M file ad ruig resuls oly. (Noe: please add brief bu clear commes o your M file, ad add ile ad/or leged o your plos if ecessary) Figure 1. Periodic Sigal x () rigoomeric Fourier Series: x( ) a0 = + a cos w0 + b si w0 (a) = 1 Compac rigoomeric Fourier Series: 0 0 = 1 x( ) = c + c cos( w + θ ) (b) Wrie oe M file (by groupig all your Malab commads i oe file ad save i as M file) o do he followig asks: (1) Calculae he coefficies of he rigoomeric Fourier series, a 0, a ad b, where = 1, 2,, 5. (2) Calculae he coefficies of he compac rigoomeric Fourier series, c 0, c ad θ, where = 1, 2,, 5. (Hi: may eed fucio aa2 ad sqr ) (3) Plo he magiude ad phase specra of x() based o he resuls obaied i (2). (4) Deoe by ~ x ( ) he approximaio of x () obaied by summig he firs 6 erms of (icludig he DC erm) of he Fourier series obaied i (a). Plo ~ x ( ) for 0 10π. (5) Plo he origial fucio x () for 0 10π i he same graph of (3) so ha hey ca be compared. (6) Repea (1) o (5) for 31 erms.
MALAB uorial rigoomeric Fourier Series MALAB ca be used o fid ad plo he rigoomeric Fourier series of a periodic fucio. Usig he symbolic mah oolbox, we ca also perform he iegraios ecessary o fid he coefficies a 0, a, ad b i he case of he rigoomeric series. rigoomeric Fourier Series For he periodic waveform show below: f() 4-1 3 6-2 10 he sigal, f() has a period, = 7. hus, w o = 2π/7, ad he Fourier series expasio is: where: f () = a 0 + # a cos! 0 + # b si! 0 =1 =1 a 0 2 # f ()d a # f ()cos! 0 d b # f ()si! 0 d Usig MALAB we ca fid hese coefficies as follows: >> syms >> a0=(1/7)*(i(4,,-1,3)+i(-2,,3,6)) >> a=(2/7)*(i(4*cos(*2*pi*/7),,-1,3)+ i(-2*cos(*2*pi*/7),,3,6)) >> b=(2/7)*(i(4*si(*2*pi*/7),,-1,3)+ i(-2*si(*2*pi*/7),,3,6)) We ca plo hese coefficies as a fucio of. We eed wo plos, oe for he a coefficies ad oe for he b coefficies. I his case we will plo he values for 0 20, usig he followig MALAB commads:
>> vals=1:20; >> avals=subs(a,,vals); >> bvals=subs(b,,vals); >> subplo(2,1,1) >> sem([0,vals],[double(a0),avals]) >> subplo(2,1,2) >> sem([0,vals],[0,bvals]) Noe ha we use he sem fucio o plo hese coefficies sice hey are discree values ad o a coiuous fucio. hese commads should resul i he followig pair of plos: A simple approximaio o he waveform f() ca be foud if we iclude he erms from 0 2. I his case: 2 f ()! a 0 + # a cos 0 + # b si 0 =1 2 =1
his approximaio is foud usig he followig MALAB commads: >> vals=1:2; >> fapprox=double(a0)+sum(subs(a*cos(2**pi*/7),,vals))+ sum(subs(b*si(2**pi*/7),,vals)) ad he ploed alog wih he origial fucio usig: >> vals=-1:.01:6; >> fapproxvals=subs(fapprox,,vals); >> fexac=[4*oes(1,401),-2*oes(1,300)]; >> plo(vals,fapproxvals,vals,fexac) his resuls i he followig plo: We ca see ha he Fourier series expasio does approximae he fucio, however, he approximaio is o very good. We ca improve he approximaio by icludig a greaer umber of erms. If we repea he MALAB commads give above for 0 20:
>> vals=1:20; >> fapprox=double(a0)+sum(subs(a*cos(2**pi*/7),,vals))+ sum(subs(b*si(2**pi*/7),,vals)) >> fapproxvals=subs(fapprox,,vals); >> plo(vals,fapproxvals,vals,fexac) which resuls i: