Documente Academic
Documente Profesional
Documente Cultură
k
t jk
k
o
e a t x
0 /
# /40
%here
3 3
5 6
is the fundamental fre"uency. To determine the )ourier series coefficients from a
timedomain formula for the signal over one period# %e must evaluate the analysis integral for every
integer value of k7
To
o
t jk
k
dt e t x
T
a
3
0 /
3
4
/60
%here
3 3
5 6 T
is the fundamental period. If necessary# %e can evaluate the analysis integral over
any
period8 in /60 the choice 93# T3: is sometimes a convenient one# but integrating over the interval 9-; T3
# ;T3: %ould also give exactly the same ans%er.
" Pre-Lab
In this lab# %e %ill use a feature of LabI,W that allo%s you to evaluate integrals by numerical
approximation. LabI,W has several numerical integration functions# such as <Lobatto
=uadrature.vi> or <4? numeric integration.vi># that are very po%erful methods for evaluating
integrals of functions specified by formulas. The <formula> for the integrand must be %ritten
similarly to a .ath&cript function. Then the numerical integration function %ill adaptively figure
out the best %ay to approximate the integral %ith a sum. We can use these functions to evaluate
)ourier &eries integrals and then %e %ill plot the resulting )ourier &eries coefficients *ak+ to
display the spectrum.
2.1 Numerical Integration
The basic idea of numerical integration is to approximate an integral %ith a sum# and the
simplest %ay to do this is %ith the @iemann sum7
,
_
L
a b
t f dt t f
b
a
L
n
n
4
0 / 0 /
%here the <sampling points>
n
t
are ( ) +
6
4
n a t
n
# and
L
a b
. The parameter is
actually the %idth of subintervals defined by breaking the interval 9a# b: into L e"ual siAed
subintervals. The sampling points are taken to be the mid-points of those subintervals.
4
)igure 47 $pproximating the area under f/t0 %ith the area of many narro% triangles.
The theory of @iemann integration /in calculus0 tells us that taking the limit as L %ill make
the sum on the right converge to the integral on the left in /B0. )urthermore# if %e think of the
integral as calculating area# then the @iemann sum is approximating the area %ith the sum of
areas of many rectangles %hose %idth is and %hose height is
( )
n
t f
. We could get a better
4
We could define tn to be at one of the endpoints of the interval# and the same results %ould be obtained /in the limit0 for
approximating the integral %ith a sum.
approximation to the area if %e used trapeAoids instead of rectangles to compute the area under
the curve
( ) t f
. Carrying this idea to the next step# %e can use polynomial approximations to
( ) t f
to get even more accurate area approximations.
2.2 Integrate a Simple Function with La!I"#
&uppose that %e %ant to calculate the value of the definite integral
6
.
( ) D cos
E
3
dt t
In LabI,W# this can be done as a numerical approximation %ith functions such as the Lobatto
=uadrature.
2.2.1 Numerical Integration with Loatto $uadrature
In order to use the Lobatto =uadrature# %e must pass three arguments7 the function definition /of
the integrand0# and also the lo%er and upper limits of integration. The limits of integration are
scalar constants. You can pass the integrand in text in the same format as the .ath&cript node.
Fere is an example7
3 Warmup
In the %arm-up you %ill use the "uadrature to do more complicated integrals# such as those
needed in )ourier &eries analysis /60 to extract the )ourier coefficients#
k
a
.
%.1 &iecewise 'e(inition o( a Signal
.any signals are defined by giving several cases that define pieces of the overall signal. )or
example# the s"uare %ave is one for part of its period and Aero for the rest. There are a couple of
%ays of dealing %ith cases %hen %riting the function definition for "uadG. The tricky part is
making sure that the auxiliary function can handle a vector input. Pay careful attention to the
%arning in the help for "uadG that states7
= 1 =H$?G/-)-#$#I0 approximates the integral of )/J0 from $ to I... -)-
is a string containing the name of the function. The function must return
a vector of output values if given a vector of input values.
In other %ords# you must have a vector output if called by "uadG.E It helps to vectoriAe the cases8
perhaps by using the find function or %ith vectoriAed logical tests.
2
This easy example %as chosen so that you can check the result by hand.
/a0 Consider the problem of plotting the triangle %ave of )ig. 6 In order to define the
%aveform so that you can plot it over any interval# it is necessary to figure out t%o things7
ho% to plot one period of the signal# and then ho% to plot other periods. In this part# %rite
an auxiliary function that %ill define the triangle %ave over one period from t 1 3 to t 1
3.3'. In other %ords# convert the follo%ing mathematical statement into vectoriAed
.$TL$I code7
There are t%o %ays to approach this /use either one to %rite your triangle %ave function07
)igure 67 Triangle Wave re"uires a piece%ise definition.
/i0 Hse the find or search 4? array function to identify the subset of inputs associated
%ith each case. )or example# jkl = find(tt>=0 & tt<=1); yy =
exp(tt(jkl))8 %ill define a signal that is
t
e over the interval 3 K t K 4.
/ii0 ?efine one period of the triangle %ave by using unit-step signals to isolate
different regions of the signal. )or example# you can define
( ) ( ) ( ) [ ] 4 t u t u e t f
t
by %riting
function out = myfunc(tt)
out = exp(tt).*((tt>=0)-(tt>=1));
The logical expression ((tt>=0)-(tt>=1)) evaluates to 4 if the condition /3
K t K 40 is true and it evaluates to 3 if the condition is false. Thus# multiplying by
((tt>=0)-(tt>=1)) has the effect of <s%itching on> the exponential
function over the desired set of values of tt. You can use this techni"ue to s%itch
on and off various pieces of the function definition as re"uired in /'0. Lotice that
the t%o cases of the triangle %ave define in /'0 can be %ritten as7
/b0 !ne simple %ay to make the function definition periodic is to use the mod/0 function
%hich is defined in mathematics as a remainder function that gives a positive ans%er#
e.g.# mod/4.4E# 3.E0 is 3.4E because %hen 4.4E is divided by 3.E the integer "uotient is 6
and the remainder is 3.4E. )or negative numbers# the example mod/M3.N# 3.E0 1 3.B is
true because M3.N 1 3.E/M60 2 3.B. Consider the follo%ing vector example7
tt = -1:0.01:1; plot( tt, co(pi*mod(tt,0.!)) )
Hse this idea to define the periodic triangle %ave# but put the mod/0 operation inside the
.-file that defines the triangle %ave.
/c0 Hse your triangle %ave function and fplot to make a plot of the triangle %ave over the
time interval 3.OE K t K 4.3E.
#nstructor erification /separate page0
/d0 &ho% that you can calculate the ?C value of the triangle %ave by integrating over any
one period of the signal. )or example# you can do the integral from t 1 M3.36 to t 1 23.368
or from t 1 3 to t 1 3.3'. ?o the integral over both ranges and compare.P @emember to
divide by the period. Compare your ans%er to the correct ans%er %hich you can obtain
by hand.
#nstructor erification /separate page0
%.2 )sing &arameters in the Integrand
$ Lab E%ercises: Fourier Series &oefficients
In this lab# the ob(ective is to create a set of functions that %ill enable us to do the follo%ing7
4. ,valuate the )ourier &eries coefficients for the follo%ing periodic signal %hich is defined over
one period to be7
0 433 sin/ 6'3 0 / t t x
for
433
4
3 t /P0
The period is 45433 seconds. This signal is called a full-%ave rectified sinusoid# because it
contains only the positive lobe of the sinusoidal function. &uch signals and their )ourier &eries
are often used in ?C po%er supply design.
6. &ynthesiAe approximations to x/t0 using a finite number of )ourier &eries coefficients *a
k
+.
N
N k
kt T ej
k N
a t x
0 5 6 /
3
0 /
%here 6L24 is the number of terms used to form the signal and T3 is the period.
B. &tudy and explain the convergence of the )ourier &eries as N .
Write do%n the )ourier &eries integral that must be evaluated for the x/t0 given in ,". /P0. It is
relatively easy to evaluate this integral using the techni"ues of calculus /re"uired in &ection '.'0#
but first %e are going to <do> this integral numerically.
*.1 Function (or Fourier Synthesis
In this pro(ect %e are going to determine )ourier series representations for periodic %aveforms#
synthesiAe the signals# and then plot them. In general# the limits on the sum in /40 are infinite# but
for our computational purposes# %e must restrict the limits to be a finite number L# %hich then
gives the 6L 2 4 term approximation7
N
N k
kt T ej
k N
a t x
0 5 6 /
3
0 /
/N0
*.1.1 Fourier Synthesis: Sum o( +omple, ",ponentials
This synthesis can be done %ith a <sum of complex exponentials> function similar to that %ritten
for Lab Q6. That %as called syn sin. The re"uired calling se"uence of the ne% function# called
syn fourier# is given belo%. This function implements the computation given in /N0. When %e use
syn fourier for )ourier synthesis# the vector of fre"uencies %ill consist of fre"uencies that are all
integer multiplies of the fundamental fre"uency. In addition# %e must include both the positive
and negative fre"uency components. Therefore# the input vector of complex amplitudes k
a
%ill
be a vector of length 4 6 + N L containing the
+ *
k
a
)ourier coefficients in the order
+ #...# # # 4 0#...# 4 / # *
4 3 N
a a a a N a N a
and the vector
k
f
should contain the harmonic
fre"uencies
+ #...# # 3 # #...# 0 4 / # *
3 3 3 3 3
Nf f f f N Nf
%here 3 3
4 T f
is the fundamental
fre"uency of the periodic signal.
You must %rite a I /called syn fourier0 that %ill synthesiAe a %aveform from complex
amplitude and fre"uency information.
&everal examples of )ourier synthesis of a s"uare %ave are given in the text. )or E3R duty cycle
s"uare-%ave case# the )ourier coefficients are given by the formula7
( )
'
3 4
3 4
4
k
k e
k j a
jk
k
This s"uare-%ave makes a convenient test case %hen you debug your function.
2.1 *.2 'e(ining a -ecti(ied Sinusoid
In this part# use the signal definition given in ,". /P0.
/a0 Write the auxiliary function that %ill be needed to define x/t0. ?efine the parameters
carefully. Turn in the code for this function.
/b0 .ake a plot of x/t0 from ,". /P0 over t%o periods of the signal7 use the range M45433 K t K
45433. Fint7 you can use the <"uotient and remainder> I to force periodicity in a
definition. $ll you need to do is replace t by the remainder of t divided by T
3
so that you
al%ays evaluate the function over the base period of definition. Fere is an example that
sho%s the periodicity of a sa%tooth %ave7
fplot("mod(t,#).*(mod(t,#)>=0 & mod(t,#)<=1)",$-!,!%,&00);
%ith a period of T3 1 B secs. /The argument 633 is used to force L1633 or larger in fplot.0
/c0 ,valuate the ?C value of x/t0 using numerical integration. @emember that this is also the
a
3
)ourier &eries coefficient.
*.% Fourier +oe((icients (or a Full.#a/e -ecti(ied Sine #a/e
/a0 In this case# the integrand is
( )
( ) kt T j
e t x
3
5 6
so it is necessary to define another auxiliary function and introduce another parameter# the
parameter k. Write this auxiliary function /and turn in the code for it0.
/b0 Write a .$TL$I function that %ill evaluate the )ourier &eries coefficients for the rectified sine
%ave for
N N k #...# 6 # 4 # 3 # 4 #...#
. The function %ill contain a for loop to do all the
coefficients from k 1 ML to k 1 2L. It should return a vector containing 6L24 elements %hich are
the
{ }
k
a coefficients. Turn in the code for this function.
/c0 Hse the auxiliary function %ritten in the previous part to evaluate the )ourier &eries coefficients
for x/t0 from ,". /P0. )ind the { }
k
a coefficients for ME K k K E# and make a table of magnitude
and phase versus k.
/d0 In this part# you must synthesiAe a set of %aveforms using different numbers of )ourier
coefficients. Call the syn fourier synthesis function that generates xL/t0 from a finite
number of terms. ?o the cases for L 1 6# L 1 ' and L 1 G.N )or each of these synthesiAed
signals make a plot sho%ing the synthesiAed signal xL/t0 and the desired x/t0 on the same
plot. Hse a three-panel subplot to sho% the three cases on one page.
/e0 ,xplain ho% you are getting convergence as L increases. ?etermine the %orst-case
approximation error for each value of L in part /d0. In other %ords# determine %here the error
bet%een the true signal and the )ourier approximation is the largest# and also record the siAe of
that error.
/f0 Fo% large do you have to make L so that you cannot see any difference bet%een x/t0 and xL/t0 on
a plot sho%n on the computer screenD
/g0 ,xplain the empirical observations about convergence in the previous t%o parts by looking at the
magnitudes of the
k
a
coefficients. In other %ords# explain %hat happens %hen you truncate the
)ourier &eries sum in ,". /40 to get the finite sum in ,". /N0. ,xamine the siAe of the terms that
are omitted. Hse the siAe of the omitted terms to (ustify your choice of L in the previous part.
*.* 0athematical 'eri/ation
?erive the mathematical formula for the )ourier &eries coefficients for x/t0 in ,". /P0. erify that your
formula matches the numerical computation that you did in &ection '.B/c0.
Lab 13
#NS'!U&'(! E!#F#&)'#(N S*EE'
)or each verification# be prepared to explain your ans%er and respond to other related "uestions that the
lab T$-s or professors might ask. Turn this page in at the end of your lab period.
Lame7 SSSSSSSSSSSSSSSSSSSSSSSSSSS ?ate of Lab7SSSSSSSSSSSS
Part B.4/c0 Write a function that defines a periodic triangle %ave# and make a plot of the signal.
erified7 SSSSSSSSSSSSSSS ?ate5Time7SSSSSSSSSSSSS
Part B.4/d0 Hse numerical integration to get the ?C value of the periodic triangle %ave. &ho% that the
ans%er does not depend on %hich period is used in the integral. ?erive /via mathematics0 the numerical
value of a3 in the space belo%7
erified7 SSSSSSSSSSSSSSS ?ate5Time7SSSSSSSSSSSSS