**Unformatted text preview: **Matlab Project 3 EB 228-045 j gh 4/21/06 The purposes of these team Matlab project assignments are to introduce the student to the use of Matlab, to use Matlab
as a tool to learn the theory presented in lecture and to analyze more complicated systems than pencil and paper
conveniently allow, and to introduce the student to team project work. The BB 228 class is to form into two or three
person teams for the Matlab assignments; teams can be greater than three, but the larger teams will require the prior
approval of the instructor. For the submittal of each assignment, each team will submit one report, with each team
member providing one thoughtful, reﬂective paragraph discussing what they have learned. All students are to read Chapter 21 in their text. Matlab is available on computers in the Digital Senior Project Lab
(20-118) which should be open from 8:00am to 6:00pm Monday through Friday, and 9:00am to 1:00pm on Saturdays.
The BB 368 lab (20-113) also has a copy of Matlab installed on each of its machines. Access to the BB 368 lab will be
limited to periods outside scheduled lab times. Request access to the lab at the Senior Project window — your name
should be on a list ﬁom the BB 228 class list. The team members are to learn the use of the Matlab through the online
documentation and/or the Matlab supplied tutorial and/or through the use of the text material in Chapter 21. Each team
is to enter the following Matlab m-ﬁle code and execute it. The exponential form is used for the calculation of the
Fourier series. The engineer who coded the m-ﬁle below made an error. The error resulted from the fact that the
periodic function of time exhibited half-wave symmetry, and the code for the indexing of the coefﬁcients does not take
this into account. Correct the code, and display the correct ﬁgures. Note the similarity in the magnitude and phase
displays for either version of the code, but the serious mistake in the signal output resulting from the use of the
uncorrected code. Let this observation be a warning for relying on using the output of a computer without anticipating
the correct answer or at least checking it, as good engineers do. Also, note the Gibbs phenomena in the reconstructed
signal for nmax=30; you can increase the value of nmax to ﬁirther explore this phenomena. The report is to consist of a
commented version of your corrected m-ﬁle code, the magnitude and phase displays for both nmax = 5 and 30 for the
corrected version of the code, and the individual paragraph from each of the team members discussing what they have
learned from the experience. The report is due Friday May 5. %script: fscalcm %example of a Fourier series m-ﬁle. This is based upon Example 21.34 in your text. The signal x(t) has a period
% T = 20 ms, and the exponential form of the Fourier series is given by X[0]=0 and X[k]=j/(k*pi), k~=0. The code
%plots the two-sided magnitude and phase spectrum and its one-period reconstruction to 5 harmonics
%and 30 harmonics. nmax=5; n=[l :nmax]; j=Sqrt(-1); xk=—j./(n*pi); k=[-ﬂiplr(n) 0 n]; Xk=[conj(ﬂiplr(xk)) 0 xk]; subplot(3, 1, 1) stem(k,abs(Xk)) %title(‘magnitude of X[k]‘)
xlabel('frequency index k')
ylabel(lekll') subplot(3, 1,2) stem(k,angle(Xk)) %title('phase of X[k]')
%xlabel('frequency index k')
ylabel(’phase (rad)') T=0.2; t—=0:0.001:T; xp=0; for m=1:length(k); xp=xp+Xk(m)*exp(i*2*pi*k(m)*t/T); end
. xpr=real(xp); subplot(3,],3) p10t(t,XPr) title('partial sum of Fourier series xn(t)')
xlabel(‘frequency in Hz') ylabel(‘xn(t)') If you wish to learn more about Matlab, as a challenge (not required), replace the for loop with vector operations. ...

View
Full Document

- Spring '08
- HARRIS