Solutions to Assignment 5 - Initial Set...
Transcript of Solutions to Assignment 5 - Initial Set...
EE351–Spectrum Analysis and Discrete Time Systems (Fall 2005) SOLUTIONS
Solutions to Assignment 5
1. Consider the following discrete-time periodic signal:
x[n] = 1 + sin
(
2π
5n
)
+√
3 cos
(
2π
5n
)
+ cos
(
4π
5n +
π
2
)
(10)
[2] (a) The fundamental period of x[n] is N = 5 and the fundamental frequency of x[n]is ω0 = 2π
N= 2π
5.
[4] (b) To find the Fourier series coefficients for x[n], simply express x[n] as follows:
x[n] = 1 +1
2j
[
ej(2π/5)n − e−j(2π/5)n]
+
√3
2
[
ej(2π/5)n + e−j(2π/5)n]
+1
2
[
ej[(4π/5)n+π/2] − e−j[(4π/5)n+π/2]]
= 1 +
(√3
2+
1
2j
)
ej(2π/5)n +
(√3
2− 1
2j
)
e−j(2π/5)n
+
(
1
2ejπ/2
)
ej2(2π/5)n +
(
1
2e−jπ/2
)
e−j2(2π/5)n (11)
Thus, the FS coefficients are:
a0 = 1→ |a0| = 1; ∠a0 = 0
a1 =
√3
2+
1
2j=
√3
2− 1
2j → |a1| = 1; ∠a1 = tan−1
(
− 1√3
)
= −π
6
a−1 =
√3
2− 1
2j=
√3
2+
1
2j → |a−1| = 1; ∠a−1 = tan−1
(
1√3
)
=π
6
a2 =1
2ejπ/2 → |a2| =
1
2; ∠a2 =
π
2
a−2 =1
2e−jπ/2 → |a−2| =
1
2; ∠a−2 = −π
2a3 = a−2; a4 = a−1
[4] (c) Plots the magnitude and phase spectra over two periods are shown in Figure 18.
2. Let x[n] be a periodic signal with fundamental period N and FS coefficients ak.
[4] (a) First Difference: Let y[n] = x[n− 1]. The Fourier series coefficients bk of y[n] canbe computed as follows:
bk =1
N
∑
<N>
y[n]e−jkω0n =1
N
∑
<N>
x[n− 1]e−jkω0n
=1
N
∑
<N>
x[n]e−jkω0(n+1) =1
N
∑
<N>
(
x[n]e−jkω0ne−jkω0
)
=
(
1
N
∑
<N>
x[n]e−jkω0n
)
e−jkω0 = ake−jkω0 = ake
−jk(2π/N)
Electrical Engineering, University of Saskatchewan Page 21
EE351–Spectrum Analysis and Discrete Time Systems (Fall 2005) SOLUTIONS
� � � � � � � � � � �
|| ka
k
� � � � �
��� � �����
� �
��� � ��� �
�
�
�
�
� �
�
�
�
� �k
ka∠
6/π−
2/π
2/π−
6/π
6/π−
2/π
2/π−
6/π
Figure 18: Magnitude and phase spectra of x[n] (plotted over two periods).
Hence x[n− 1]FS←→ ake
−jk(2π/N) and it follows that:
x[n]− x[n− 1]FS←→ ak
[
1− e−jk(2π/N)]
[3] (b) Now let
x[n] =
{
1 0 ≤ n ≤ 70 8 ≤ n ≤ 9
(12)
be a periodic signal with fundamental period N = 10 and Fourier series coefficientsak. Then the fundamental frequency of x[n] is ω0 = 2π/N = 2π/10. Also, let
g[n] = x[n]− x[n− 1] (13)
be a periodic signal with fundamental period N = 10 and Fourier series coefficientsak. Also, let
g[n] = x[n]− x[n− 1]
Clearly, g[n] has the same fundamental period N = 10. The function g[n] can bewritten as
g[n] =
1, n = 00, 1 ≤ n ≤ 7−1, n = 8
0, n = 9
(14)
Plot of g[n] in one period is shown below.
Electrical Engineering, University of Saskatchewan Page 22
EE351–Spectrum Analysis and Discrete Time Systems (Fall 2005) SOLUTIONS
0 1 2 3 4 5 6 7 8 9−1
−0.8
−0.6
−0.4
−0.2
0
0.2
0.4
0.6
0.8
1g[n]
n
Figure 19: Plot of g[n] over two periods.
[3] (c) The Fourier series coefficients of g[n] can be computed as follows:
bk =1
N
∑
<N>
g[n]e−jkω0n =1
10
9∑
n=0
g[n]e−jkω0n
=1
10
[
e−jkω00 − e−jkω08]
=1
10
[
1− e−jk(2π/10)8]
(d) Since g[n] = x[n]−x[n− 1], using the first-difference property established earlier,the Fourier series coefficients ak and bk are related as follows:
[2]bk = ak − e−jk(2π/10)ak (15)
Hence,
ak =bk
1− e−jk(2π/10)=
(1/10)[
1− e−jk(2π/10)8]
ak − e−jk(2π/10)ak
(16)
Electrical Engineering, University of Saskatchewan Page 23
EE351–Spectrum Analysis and Discrete Time Systems (Fall 2005) SOLUTIONS
3. (MATLAB)(a)
[5]function a=dtfs(x);
N=length(x); % The fundamental period of x
a=zeros(1,N); % Initializing the vector of FS coefficients
for k=1:N
for n=0:N-1
a(k)=a(k)+x(n+1)*exp(-j*(k-1)*(2*pi/N)*n);
% Note how the indexes k and n are entered in the exponent of exp(.)
end
a(k)=a(k)/N;
end
(b)
[7]% Computing the FS coefficients using dtfs
Nvec=[32,64,128,256,512];
for h=1:length(Nvec)
N=Nvec(h);
x=0.9.^[0:N-1];% create one period of x[n], a decaying exponential
t0=clock; % set t0 to the current time
X=dtfs(x); % store the DTFS of x[n] in X
dtfstime(h)=etime(clock,t0); %store the elapsed time in vector dtfstime;
end
% Repeat using fft
for h=1:length(Nvec)
N=Nvec(h);
x=0.9.^[0:N-1];% create one period of x[n], a decaying exponential
t0=clock; % set t0 to the current time
X=fft(x)/N; % store the DTFS of x[n] in X
ffttime(h)=etime(clock,t0); %store the elapsed time in vector ffttime;
end
p1=loglog(Nvec,dtfstime,’marker’,’none’,’color’,’k’,’linewidth’,1.0);
hold on;
p2=loglog(Nvec,ffttime,’marker’,’none’,’color’,’k’,’linewidth’,1.0,’linestyle’,’--’);
xlabel(’{\itN}’,’FontName’,’Times New Roman’,’FontSize’,16);
ylabel(’Elapsed Time (sec)’,’FontName’,’Times New Roman’,’FontSize’,16);
set(gca,’FontSize’,16,’FontName’,’Times New Roman’);
The results of dtfstime and ffttime obtained in my computer are listed below:
dtfstime =
1.6000e-002 4.7000e-002 1.8700e-001 7.3400e-001 2.9540e+000
ffttime =
0 0 0 0 0
Electrical Engineering, University of Saskatchewan Page 24
EE351–Spectrum Analysis and Discrete Time Systems (Fall 2005) SOLUTIONS
It appears that fft is too fast for timing. Finally, Figure 20 plots dtfstime usingloglog.
101
102
103
10−2
10−1
100
101
N
Ela
psed
Tim
e (s
ec)
Figure 20: Plot of dtfstime.
Electrical Engineering, University of Saskatchewan Page 25