You are on page 1of 3

Gleb Danilchenko EE 3512: Signals

Midterm 1, Question 3 Question #3, Fourier Series

We can first examine the signal as three different parts, as F(t) = 1 from 0 < t < T/4, then as F(t) = -1 from T/4 < t < T/2, and last as F(t) = 0 from T/2 < t < T. Since this piecewise function is neither even nor odd over the y-axis, we need to compute both the An and Bn terms in the Fourier series. Also, from inspection we can see that the average value of F(t) over the period T is zero, hence the A0 term is zero. In MATLAB, this is easily verified by ”A0 = (2/T)*(int(1,t,0,T/4)-int(1,t,T/4,T/2));” which equates to zero. Since the function is zero for the second part of the period T, we need only to compute two integrals for each of the An and Bn terms, both shown in the analytical solution and MATLAB code. Using the Symbolic Toolbox with MATLAB, we can set our time (t) and number of divisions (n) to a symbolic variable, and then compute each piecewise integral for An and Bn, with the period T being any value or by making T symbolic. From there, we can easily create an “F” function that is “An*cos(n*w0*t) +Bn*sin(n*w0*t)”, after this we need to perform the summation over M number of terms to clear the n variable out of F. By choosing more M terms, the computation takes longer in MATLAB, but will produce a more accurate result. The graphs below show examples of F(t) that is the result of summing the previous F from 10, 50, and 100 terms. To create the graph of each An, Bn, and combined Cn terms, we can create a for loop, from i = 1 to M, to store the value of the respective term when n = i, by solving the symbolic Cn at that n value, then storing it into a double type matrix. What the result is when we plot stem(CnValue), is the amplitudes of Cn at each of the harmonics in the series, the plots of An and Bn are also shown. Both results verify the analytical solution, we see that An has a zero value at even harmonics, and Bn has a pattern of a value at n = 2, then each next fourth harmonic, while the rest are zero. Analytical Solution To = T so Wo = 2 π /T; A0 = 2/T ∫ f (t ) * cos( n 2πt / T ) dt
0 T /4 T

Since cos(2 π t) is an even function, A0 = 0.
T /2

An = 2 / T


0

(1) * cos( n 2πt / T )dt - 2 / T
T /4

An = 1 / nπ[(sin( nπ / 2)) ] - 2 / nπ[sin( nπ) −sin( nπ / 2)] sin An = 1 / nπ[sin( nπ / 2) − ( nπ) +sin( nπ / 2)] sin An = 1 / nπ[2 * sin( nπ / 2) − ( nπ)] An = 0 for when n is even. An = 2 / nπ for n = 1, 5, 9, 13 etc An = - 2 / nπ for n = 3, 7, 11, 15 etc
T /4

An = 2 / T [ (T / n 2π ) * (sin( n 2πt / T )) ] 0

- 2 / T [ (T / n 2π ) * (sin( n 2πt / T )) ] T / 4
T /2

T /4

∫ (1) * cos( n 2πt / T )dt

Bn = 2 / T


0

(1) * sin( n 2πt / T )dt - 2 / T

T /2

T /4

∫ (1) * sin( n 2πt / T )dt

Fourier Series T /2 Bn = 2 / T [(T / n 2π ) * −(cos( n 2πt / T )) ] 0 + 2 / T [ (T / n 2π ) * (cos( n 2πt / T )) ] T / 4 Bn = 1 / nπ[−cos( nπ / 2)+1 +cos( nπ) −cos( nπ / 2)] Bn = 1 / nπ[−2 cos( nπ/ 2)+cos( nπ) +1] = 1 / nπ[cos( nπ) −2 cos( nπ / 2)+1] Bn = 0 for n = 1. 10. Question 3 Question #3. 8.  s i4π n* t /(T ) + 1/ 3s i (1n π 2* t / T ) + 1/ 5* s i2 nπ 0* t(/ T ) + 1/ 7 * s i2 nπ 8* t(/ T )  Produced Results Cn (top). etc. 7. . with 10. Bn = 2 /(( n / 2)π) for n = 2. and 100 summations. period 4 π . 4. etc. 5. . 6. . 14. 50.Gleb Danilchenko EE 3512: Signals T /4 Midterm 1.  2 /π  . 3. and Bn (right) values. Graphs of F(t). . F(t) =  c o2π *st / T() − 1/ 3* c o6π *st / T() + 1/ 5* c o1 π s0*t /(T ) + . An (left). .

i)).'Name'.1.'F(t) reconstructed').0. clc.5). t. An2 = (2/T)*int(-1*cos(t*n*w0).1. Bn1 = (2/T)*int( 1*sin(t*n*w0).T/4. t. reconstructed with M summations. end %% Plots F(t). 0.'LineWidth'.grid.T/4) int(1.1:2).ylabel('Cn amplitudes'). T/4). % Clear command window.T/2.ylabel('Bn amplitudes'). period of 4pi figure(1). 0. for i=1:1:M AnValue(i) = double(limit(An. T/4. An1 = (2/T)*int( 1*cos(t*n*w0). % Plot Bn values subplot(2.n. T/4.grid. % Integral An from 0 . xlabel('n').T/2)). BnValue(i)^2).set(1. Bn2 = (2/T)*int(-1*sin(t*n*w0).2. % Cn = simplify(sqrt(An^2 + Bn^2)).3).Gleb Danilchenko EE 3512: Signals Midterm 1.1.'LineWidth'. Fourier Series Matlab Code clear all. w0 = 2*pi/T.T/4.grid.t. Question 3 Question #3. xlabel('n'). t. end %% Calculates Bn line spectra BnValue = zeros([1 M]).M). % Plot An values subplot(2.5).T/4 % Integral Bn from 0 .5).'Name'. for i=1:1:M BnValue(i) = double(limit(Bn. for i=1:1:M CnValue(i) = sqrt(AnValue(i)^2 + . xlabel('n'). i)). T/2). % Integral Bn from 0 .set(2. stem(CnValue. . %% Plot Cn values figure(2). An = An1 + An2.. subplot(2.4).2. %% Calculates An line spectra AnValue = zeros([1 M]). T = sym('4*pi'). M = 50.t.'LineWidth'.1.ylabel('An amplitudes'). Bn = Bn1 + Bn2. A0 = (2/T)*(int(1.'Cn values').. % Clear variables and functions from memory. [0:8*pi]).2. syms n t. end %% Calculates the Cn line spectra CnValue = zeros([1 M]). stem(AnValue. Ft = symsum(F. t.T/4 % Integral An from T/4 . T/2). stem(BnValue. T/4). F = simplify(An*cos(n*w0*t) + Bn*sin(n*w0*t)).grid off. ezplot(Ft.