298 C H A P T E R 4: Frequency Analysis: The Fourier Series
Use MATLAB to compute and plot the approximationˆx(t)and the errrorεfor increasing values ofN
from 1 to 100.
(d) Concentrate your plot ofˆx(t)around the one of the discontinuities, and observe the Gibb’s phe-
nomenon. Does it disappear whenNis very large. Plotˆx(t)around the discontinuity forN=
1000.
4.27. Walsh functions—MATLAB
As seen in Problem 4.26, the Fourier series is one of a possible class of representations in terms of orthonor-
mal functions. Consider the case of theWalsh functions, which are a set of rectangular pulse signals that
are orthonormal in a finite time interval[0, 1]. These functions are such that: (1) they take only 1 and− 1
values, (2)φk( 0 )= 1 for allk, and (3) they are ordered according to the number of sign changes.
(a) Consider obtaining the functions{φk}k=0,... ,5. The Walsh functions are clearly normal since when
squared they are unity fort∈[0, 1]. Letφ 0 (t)= 1 fort∈[0, 1]and zero elsewhere. Obtainφ 1 (t)with
one change of sign and that is orthogonal toφ 0 (t). Find thenφ 2 (t), which has two changes of sign
and is orthogonal to bothφ 0 (t)andφ 1 (t). Continue this process. Carefully plot the{φi(t)},i=0,..., 5.
Use the MATLAB functionstairsto plot these Walsh functions.
(b) Consider the Walsh functions obtained above as sequences of 1 s and− 1 s of length 8 , and care-
fully write these six sequences. Observe the symmetry of the sequences corresponding to{φi(t),i=
0, 1, 3, 5}, and determine the circular shift needed to find the sequence corresponding toφ 2 (t)from
the sequence fromφ 1 (t), andφ 4 (t)fromφ 3 (t). Write a MATLAB script that generates a matrix 8 with
entries as the sequences. Find the product( 1 / 8 )88T, and explain how this result connects with the
orthonormality of the Walsh functions.
(c) We wish to approximate a ramp functionx(t)=r(t), 0 ≤t≤ 1 , using{φk}k=0,... ,5. This could be
written as
r= 8 a
whereris a vector ofx(nT)=r(nT)whereT= 1 / 8 ,aare the coefficients of the expansion, and 8 is
the Walsh matrix found above. Determine the vectoraand use it to obtain an approximation ofx(t).
Plotx(t)and the approximationxˆ(t)(usestairsfor this signal).