i. FUPVUSe ASSiAanment on Fase 4 In this lab, you will investigate the properties of orthogonal functions and the Fourier series. This is a long lab, so plan accordingly! Background reading includes:...

1 answer below »
i. FUPVUSe ASSiAanment on Fase 4 In this lab, you will investigate the properties of orthogonal functions and the Fourier series. This is a long lab, so plan accordingly! Background reading includes: 2. Background Orthogonal basis functions are central to the analysis of linear systems, The most important of these functions is the complex exponential, e’” , where @ is the angular frequency, which is real. In this laboratory exercise, we are specifically interested in the family of complex exponential basis functions, 9, (t), that are related to each other by having angular frequencies that are multiples of a common fundamental frequency, @, @, (t) = e**" (L4.1) Each function can be viewed a vector of length 1 gotating at a different frequency in the complex plane. 1 . ; g,(t) rotates at the fundamental frequency @, =—— , where 7, is the fundamental period. ¢, (r) rotates at at a frequency kw, radians/sec, where & is an integé? that ranges from—o0 fh = 2a. If n#m, the numerator in Equation (L4,3) is zero and the denominator is nonzero; hence, oh integral is zero. If n =m, both the numerator and denominator are zero and hence the integral is indeterminate. We can determine the value of the integral directly when n= m Ty Th th Lf elm™dt= 2 edt =2[1de=1 (L4.4) 0 o 0 So Equation (L4.3) reduces to qT f 1, n=m BY edt =3 L4.5 a J 0, n#m (145) as described in Equation (L4.2). Fourier series A large number of time functions, x(t), can be represented over a given time interval, [Z, ‘min > 2, vax) by the sum of an infinite number of complex exponential basis functions, each scaled by a different complex constant. This summation is called the Fourier series summation: x(t)= xe" (L4.6) k=- x0 = Hho iy oO 0 m=—20 > x ¢! fe es aig at)=s ; (L4.7) ™ ef 1, k=m 0, kem where we’ve noted from Equation (L4.5) that the quantity in the brackets in Equation (L4.7) is 1 only when k =m, so that only one term is picked out of the summation. Thus, we arrive at a pair of relations x()= ¥ x,e*™ Synthesis k=-0 Th (L4.8) M=t J x(e"dt — Analysis oO The first relation, the synthesis relation, tell how we represent an arbitrary x(t) over a given time interval, [0,7') as the sum of complex exponentials, e”*' which are multiples of fundamental frequency, @,, each one with a magnitude and phase given by the Fourier series coefficient, x, . The second relation, the analysis relation, tells how we determine the Fourier series coefficients from a given x(t), As an example, consider a pulse, x(t), of length t, = 1sec as shown in Figure 1. x) VB pee prcrceeraronstapasannnansercrnapenyrerntntntnenpatctnsienenti prose stistenen bes sscescavscnes consents isu sonia sions fan anemia ness 0.5 beers ne seheccsssesaffteee coe ponerse : 0) jane oe ceeveaee -3 -2 -1 0 1 2 3. t (secs) Figure 1: Pulse 1. The first step in performing the Fourier analysis of this function, is to choose an analysis interval. Here, we choose T,,,, = —land7,,,, =1. Hence, 7, = 7... —Thin =2- 2. Now, we compute the Fourier series coefficients, x, , using the analysis relation of Equation (L4.8). For this case, you can show that x, = 0.5Ssine(k7/2). 3. Finally, we resynthesize x(t) using the synthesis relation of Equation (L4.8). For this example, note that the sine function is even, sox, = x_, . Thus, the synthesis relation can be rewritten as x()= > xe" =x, +2) 2,08 (L4.9) k=—0 k=l Further simplifications are possible (see my Notes), but for now, this is good enough. It is useful to define *,,(4) as a resynthesis of the original x(/) by using only M of the terms of the summation in Equation (L4.9): a M x, (=x) +> x,e"™ (L4.10) k=l We can show that as the number of terms in the resynthesis, M, increases, the difference between x(¢) and x,, (¢) gets monotonically smaller. We can get a feeling for this graphically, by plotting X,,(¢) for a few values of M. 1.5 1 0.5 0 -0.5 1.5 1 0.5 0 “23 -2 “4 ) 1 2 t (secs) Figure 2: Fourier series resynthesis with 1,3 and 5 terms More precisely, we can show that £,,, the mean square error of the difference between x(t) and x aw (lisa monotonically decreasing function of M Ey, = y Ix(nP dt-TS"|x, | . (L4.11) -T/2 -M In the assignment, you will explore what happens as we analyze and resynthesis x(t) using different parameters, such as ¢, , 7, and M. 3. Assignment This assignment has three parts. First, we need to get some graphical sense of what the complex exponential functions look like. Then we discuss the orthogonality of these functions and finally, we look at how they can be used to represent arbitrary time functions using the Fourier series. 1. Visualization of g, (t) =e“ . First consider a family of complex exponential functions, g,(t) = e*®", with @, = 27/64. This means that all g,(r) is periodic with a period of 64 seconds. Create an array, x(n], that corresponds to one period of g,(¢) sampled at 1 second intervals. e ° 08 e e 08 Py *, e e o6 é . 06 ° e 04 e e 04 e ° ° e 0.2 * ° 02 2 e e > = 6 e ° = 0 e e z e e 4 02 ° e 0.2 ° e 04d e ° 0.4) e ° ° * a ° e & 06 . . 06 e e e e O8 %e, . . 08 e ° 1 *eceee® 1 . * : 1 0.5 9 05 1 0.5 0 05 i Rete} Rely} Figure 3: Complex exponential at @, (left) and 4a, (right) Plot the real vs. imaginary parts of this array. Repeat for one period of an array that corresponds to one period of g,(¢) , again sampled at one second intervals. You should get the plots of Figure 3. This should give you a visualization of g, (¢) = e”**" as a vector spinning in the complex plane at a frequency k@, radians/sec. As k increases, the speed of the rotating vector increases. Note that to plot a complex quantity, x, in Matlab you can always do this: plot (real(x), imag(x); but it is simpler to do this: plot(x); If x is a real array, Matlab plots it against the index of the array. But if x is a complex array, Matlab plots the real part against the imaginary part. Orthogonality of ¢,(¢) = e*' . We wish to investigate the orthogonality of complex exponential functions as expressed in Equation (L4.2). Although Matlab cannot deal numerically with continuoustime functions, we can create arrays, y,[n], by sampling g, (t) at multiples of some interval, A, which is an integer fraction, N, of the fundamental period. That is, t= nA, where A= T,/N . The result is ie ken kn % [n] =e" = eh D"* = Qh (L4.12) Notice that g,[7]no longer depend on @, and t, but on N and n. For example, the plots in Figure 3 correspond to g,[n] and ¢,[n] with N = 64, We now seek to show that the sampled functions, g,[n], are orthogonal, specifically that 1, k=m 1 N-1 . _ wy 2 eelmdeatel = {c kem (4.13) a. Let N=16 Create arrays g,[n] and g,[n]. Use Matlab to evaluate the summation in Equation (L4.13) for all permutations of k= 1 and 2 and m = 1 and 2. You should get four values, Do your results make sense? Note that you can be stupid or clever in evaluating the sum in Matlab. For example, if you have two complex N-pt arrays, x and y, you can compute sum(x.*conj (y) ) (stupid) or just x*y’ (clever). Why does this work? b. In the preceding part, we checked the orthogonality of @, [7] at just two values of k. Now we want check for all possible values of k. But how many & are there? Show theoretically that 9, [7] = 9, [7] for all n. Why is this? Check it with Matlab by comparing g,[n] and ¢,,, [7] for N = 16 . This shows that for an arbitrary N, there are only NV unique 9, [7]. From part b. above, we need to check orthogonality of N functions against each other. This means we have to make N* comparisons. The results are best shown in a matrix that we expect to be equivalent to the identity matrix. (Why?) (So. - Ye.g,] fi - 0 Dot Po fefic EL (L4.14) Son.o aa ¥ ay P% 0-1 Again, there are stupid and smart ways to compute this matrix with Matlab. The stupid way is with a for loop. If you do it right and exploit the properties of matrix multiplication, you should be able to create and multiply two N x N matrices together with a line or two to get the result shown in Equation (L4.14). Construction of Fourier series. Now that we’ve established the orthogonality of complex exponential functions, we are ready to look at the Fourier series in more detail. In this exercise, you’ll design a Matlab function to produce the plots of Figure 2. You’!I use the pulse, x(#), of length t, =1sec and choose T,,,, = —1and T,,,, = 1 so your plots will match those of Figure 2. Here’s the specification of the function: function plotfs(t0, T, k) PLOTFS Fourier synthesis plotfs(t0, T, k) plots resynthesis of a pulse function of width tO over analysis interval [-T/2, T/2) using the partial sum of k terms. oe a oO ale Note a few things about your results. a. As the number of terms in the partial summation of Equation (L4.9) increases, x y(t) matches x(t) increasingly well in the interval [-%4,74). b. Outside the interval [-4,74), the resynthesized function doesn’t match the original function at all well because the resynthesized function, x ,, (t) , is guaranteed to be periodic, even if x(t) is not. Why is this? Error of the Fourier series approximation. As noted in the background section of this lab, £,,, the mean-square error between the partial Fourier series approximation, x ,, (¢) and the original x(t), decreases as the number of terms in the approximation increases, as indicated by Equation (L4.11). Given the pulse, x(t), of length ¢, =Isec, T,,, =—landT,,,, =1, plot £,,as a function of M, the number of terms on a log-log scale. Consider M ranging from 1 to 1000 terms. From your plot, you should see that a. The error decreases monotonically as M increases. b. Each term that you add to the summation reduces the error by roughly a constant percentage. -3 -2 -1 0 1 2 3 t (secs) 0.6, ® - 0.4+ Irn 40 Ha 0.2+ eotenetegetozele.e ! 0 oreePegetonetone -0.2 1 ! 1 L 1 1 J -20 -15 -10 5 0 5 10 15 20 k Figure 4: Fourier series coefficients Relation of x(t) to x, . Create a function, plotk(t0, T, k), to plot the first k Fourier series. You canuse stem(..., ‘filled’) todo this. When you use both plotfs and plotk on two panels of a plot, your result should look that shown in Figure 4. Note that I have indicated in the top right corner of the bottom plot that the largest included Fourier-series component, k = 20, corresponds to a complex exponential with a frequency, f,,. =10Hz. a. b. Create plots witht, =1lsec,7 =2 andk =20. Create plots with /, = 2sec ,T = 4 and & = 20 . Compare the results of part a. and b. Note that the x(#) plotted in the upper panels are different, but the Fourier series coefficients plotted in the lower panels are exactly the same. How can this be? How can two different time functions have the same Fourier series coefficients? Create plots witht, = 1sec ,7 = 4 and k = 40 . Compare the results of part a. and c. Note that the x(t) plotted in the upper panels look the same in the range —1 co.
Answered Same DayDec 31, 2021

Answer To: i. FUPVUSe ASSiAanment on Fase 4 In this lab, you will investigate the properties of orthogonal...

Robert answered on Dec 31 2021
112 Votes
SOLUTION

Creating an array and plotting real vs. Imaginary part for k=1

Matlab code-

clear all;
clc;
N=64;
w0=2*pi/N;
for n=1:N
y1(n)=exp(i*w0*n);
n=n+1;
end
y1
plot(y1)


Result-

y1 =
Columns 1 through 6
0.9239 + 0.3
827i 0.7071 + 0.7071i 0.3827 + 0.9239i 0.0000 + 1.0000i -0.3827 +
0.9239i -0.7071 + 0.7071i
Columns 7 through 12
-0.9239 + 0.3827i -1.0000 + 0.0000i -0.9239 - 0.3827i -0.7071 - 0.7071i -0.3827 -
0.9239i -0.0000 - 1.0000i
Columns 13 through 16
0.3827 - 0.9239i 0.7071 - 0.7071i 0.9239 - 0.3827i 1.0000 - 0.0000i



Creating an array and plotting real vs. Imaginary part for k=4

Matlab code-

clear all;
clc;
N=64;
w0=2*pi/N;
for n=1:N
y4(n)=exp(i*4*w0*n);
n=n+1;
end
y4;
plot(y4)

Result-






SOLUTION

PART (a)

Matlab code-

clear all;
clc;
N=16;
w0=2*pi/N;
for n=1:N
y1(n)=exp(i*1*w0*n);
n=n+1;
end
for n=1:N
y2(n)=exp(i*2*w0*n);
n=n+1;
end
sum11=(y1*y1')/N
sum12=(y1*y2')/N
sum21=(y2*y1')/N
sum22=(y2*y2')/N

Results-

sum11 =
1
sum12 =
-5.3589e-017 +1.1123e-017i
sum21 =
-5.3589e-017 -1.1123e-017i
sum22 =
1
Conclusion-
With k and m equal, the summation is 1 but with unequal k and m, the summation is almost 0.

y1 is a row matrix with 16 columns
y1’ gives column matrix with 16 rows where each term is a complex conjugate of the corresponding
term of y1 matrix.
The multiplication of both these matrix is possible because one is a row matrix and the other is a
column matrix with equal number of terms.
Thus simply writing y1*y1' does the work.


PART(b)

Considering N=16 and k=1, y1 shall be equal to y17. Checking the same in Matlab.

Matlab code-

clear all;
clc;
N=16;
w0=2*pi/N;
for n=1:N
y1(n)=exp(i*1*w0*n);
n=n+1;
end
y1
for n=1:N
y17(n)=exp(i*17*w0*n);
n=n+1;
end
y17

Result-

y1 =
Columns 1 through 6
0.9239 + 0.3827i 0.7071 + 0.7071i 0.3827 + 0.9239i 0.0000 + 1.0000i -0.3827 +
0.9239i -0.7071 + 0.7071i
Columns 7 through 12
-0.9239 + 0.3827i -1.0000 + 0.0000i -0.9239 - 0.3827i -0.7071 - 0.7071i -0.3827 -
0.9239i -0.0000 - 1.0000i
Columns 13 through 16
0.3827 - 0.9239i 0.7071 - 0.7071i 0.9239 - 0.3827i 1.0000 - 0.0000i
y17 =
Columns 1 through 6
0.9239 + 0.3827i 0.7071 + 0.7071i 0.3827 + 0.9239i -0.0000 + 1.0000i -0.3827 +
0.9239i -0.7071 + 0.7071i
Columns 7 through 12
-0.9239 + 0.3827i -1.0000 - 0.0000i -0.9239 - 0.3827i -0.7071 - 0.7071i -0.3827 -
0.9239i 0.0000 - 1.0000i
Columns 13 through 16
0.3827 - 0.9239i ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here