254 C H A P T E R 4: Frequency Analysis: The Fourier Series
FIGURE 4.2
(a) Magnitude (top left) and
phase (bottom left) line spectra
of raised cosine and (b)
magnitude (top right) and
phase (bottom right) line
spectra of raised sine.
B
−Ω 0 Ω 0
kΩ 0
|Xk|
−Ω 0 Ω 0
kΩ 0
∠Xk
A
2
A
2
(a)(b)
kΩ 0
−Ω 0 Ω 0
|Yk|
B
A
2
A
2
2
−Ω 0
kΩ 0
Ω 0
∠Yk
−π
π
2
Using symbolic MATLAB integration we can easily find the Fourier series coefficients, and the
corresponding magnitude and phase are then plotted usingstemto obtain the line spectra. Using
our MATLAB functionfourierseriesthe magnitude and phase of the line spectrum corresponding to
the periodic raised siney(t)= 1 +sin( 100 t)is shown in Figure 4.3.
function [X, w] = fourierseries(x, T0, N)
%%%%%
% symbolic Fourier Series computation
% x: periodic signal
% T0: period
% N: number of harmonics
% X,w: Fourier series coefficients at harmonic frequencies
%%%%%
syms t
% computation of N Fourier series coefficients
for k = 1:N,
X1(k) = int(x∗exp(−j∗ 2 ∗pi∗(k - 1)∗t/T0), t, 0, T0)/T0;
X(k) = subs(X1(k));
w(k) = (k−1)∗ 2 ∗pi/T0; % harmonic frequencies
end