Beruflich Dokumente
Kultur Dokumente
1. Problem P2.1:
m=0 (m + 1) [δ (n
(a) x1 (n) = ∑10 2m 1) δ (n 2m)] ; 0 n 25.
clear; close all;
Hf_1 = figure(’Units’,’normalized’,’position’,[0.1,0.1,0.8,0.8],’color’,[0,0,0]);
set(Hf_1,’NumberTitle’,’off’,’Name’,’P2.1ac’);
%
% x1(n) = sum_{m=0}ˆ{10} (m+1)*[delta(n-2*m)-delta(n-2*m-1)]
n1 = [0:25]; x1 = zeros(1,length(n1));
for m = 0:10
x1 = x1 + (m+1)*(impseq(2*m,0,25) - impseq(2*m+1,0,25));
end
subplot(2,1,1); stem(n1,x1);
axis([min(n1)-1,max(n1)+1,min(x1)-2,max(x1)+2]);
xlabel(’n’); ylabel(’x1(n)’); title(’Sequence x1(n)’);
ntick = [n1(1):n1(length(n1))];
set(gca,’XTickMode’,’manual’,’XTick’,ntick,’FontSize’,10)
The plots of x1 (n) is shown in Figure 2.1.
(b) x2 (n) = n2 [u (n + 5) u (n 6)] + 10δ (n) + 20 (0:5)n [u (n 4) u (n 10)].
clear; close all;
Hf_1 = figure(’Units’,’normalized’,’position’,[0.1,0.1,0.8,0.8],’color’,[0,0,0]);
set(Hf_1,’NumberTitle’,’off’,’Name’,’P2.1be’);
%
% (b) x2(n) = (nˆ2)*[u(n+5)-u(n-6)]+10*delta(n)+20*(0.5)ˆn*[u(n-4)-u(n-10)]
n2 = -5:10; % Overall support of x2(n)
x2 = (n2.ˆ2).*(stepseq(-5,-5,10)-stepseq(6,-5,10))+10*impseq(0,-5,10)+...
20*((0.5).ˆn2).*(stepseq(4,-5,10)-stepseq(10,-5,10));
subplot(2,1,1); stem(n2,x2);
axis([min(n2)-1,max(n2)+1,min(x2)-2,max(x2)+2]);
xlabel(’n’); ylabel(’x1(n)’); title(’Sequence x2(n)’);
ntick = [n2(1):n2(length(n2))];
set(gca,’XTickMode’,’manual’,’XTick’,ntick,’FontSize’,10)
The plots of x2 (n) is shown in Figure 2.3.
(c) x3 (n) = (0:9)n cos (0:2πn + π=3) ; 0 n 20.
% x3(n) = (0.9)ˆn*cos(0.2*pi*n+pi/3); 0<=n<=20
n3 = [0:20];
3
4 S OLUTIONS M ANUAL FOR DSP USING M ATLAB A PRIL 98
Homework−1 : Problem 1
Sequence x1(n)
10
5
x1(n)
0
−5
−10
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
n
Sequence x3(n)
1
0.5
x3(n)
−0.5
−1
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
n
x3 = ((0.9).ˆn3).*cos(0.2*pi*n3+pi/3);
subplot(2,1,2); stem(n3,x3);
axis([min(n3)-1,max(n3)+1,-1,1]);
xlabel(’n’); ylabel(’x3(n)’); title(’Sequence x3(n)’);
ntick = [n3(1):n3(length(n3))];
set(gca,’XTickMode’,’manual’,’XTick’,ntick,’FontSize’,10)
The plots of x3 (n) is shown in Figure 2.1.
(d) x4 (n) = 10 cos 0:0008πn2 + w (n) ; 0 n 100 where w (n) is a random sequence uniformly distributed between
[ 1; 1].
Sequence x4(n)
10
x4(n)
0
−5
−10
0 10 20 30 40 50 60 70 80 90 100
n
25
20
x1(n)
15
10
0
−5 −4 −3 −2 −1 0 1 2 3 4 5 6 7 8 9 10
n
Sequence x5(n)
4
3
x5(n)
0
−8 −7 −6 −5 −4 −3 −2 −1 0 1 2 3 4 5 6 7 8 9 10 11
n
Homework−1 : Problem 2
Sequence x1(n)
30
x1(n)
20
10
−6 −5 −4 −3 −2 −1 0 1 2 3 4 5 6
n
Sequence x2(n)
60
x2(n)
40
20
−9 −8 −7 −6 −5 −4 −3 −2 −1 0 1 2
n
3. Problem P2.3: A sequence x (n) is periodic if x (n + N ) = x (n) for all n. Consider a complex exponential sequence
e jω0 n = e j2π f0 n .
8 S OLUTIONS M ANUAL FOR DSP USING M ATLAB A PRIL 98
40
x3(n) 20
−20
−40
−8 −7 −6 −5 −4 −3 −2 −1 0 1 2 3 4 5 6
n
Sequence x4(n)
50
40
x4(n)
30
20
10
0
−10 −9 −8 −7 −6 −5 −4 −3 −2 −1 0 1 2 3 4 5 6 7 8 9 10
n
or
e j2π f0 N =1 ) f0 N = K (an integer)
which proves the result.
(b) x1 (n) = cos(0:3πn); 20 n 20.
% (b) x1(n) = cos(0.3*pi*n)
x1 = cos(0.3*pi*n);
subplot(2,1,1); stem(n,x1);
axis([min(n)-1,max(n)+1,-1.1,1.1]);
Sequence x5(n)
100
80
x5(n)
60
40
20
0
−3 −2 −1 0 1 2 3 4 5 6 7
n
Problem 2.3
Sequence cos(0.3*pi*n)
1
0.5
x1(n)
−0.5
−1
−20 −15 −10 −5 0 5 10 15 20
Sequence cos(0.3*n)
1
0.5
x2(n)
−0.5
−1
−20 −15 −10 −5 0 5 10 15 20
subplot(2,2,1); stem(neo,Re_xe);
ylabel(’Re{xe(n)}’); title(’Real part of Even Seq.’);
subplot(2,2,3); stem(neo,Im_xe);
xlabel(’n’); ylabel(’Im{xe(n)}’); title(’Imag part of Even Seq.’);
subplot(2,2,2); stem(neo,Re_xo);
ylabel(’Re{xo(n)}’); title(’Real part of Odd Seq.’);
subplot(2,2,4); stem(neo,Im_xo);
xlabel(’n’); ylabel(’Im{xo(n)}’); title(’Imag part of Odd Seq.’);
8 1
0.5
Re{xe(n)}
Re{xo(n)}
6
0
4
−0.5
2 −1
0 −1.5
−10 −5 0 5 10 −10 −5 0 5 10
0.5 0.5
Im{xe(n)}
Im{xo(n)}
0 0
−0.5 −0.5
−1 −1
−10 −5 0 5 10 −10 −5 0 5 10
n n
(a) Commutation:
∞ ∞
x1 (n) x2 (n) = ∑ x 1 (k ) x 2 (n k) = ∑ x 1 (n m) x2 (m)
| {z } m= ∞
k= ∞ =m
A PRIL 98 S OLUTIONS M ANUAL FOR DSP USING M ATLAB 11
∞
= ∑ x2 (m) x1 (n m ) = x 2 (n ) x 1 ( n )
m= ∞
Association:
" #
∞
[x1 (n) x2 (n)] x3 (n) = ∑ x1 (k) x2 (n k) x3 (n)
k= ∞
∞ ∞
= ∑ ∑ x1 ( k ) x2 ( m k ) x 3 (n m)
m= ∞ k= ∞
2 3
∞ ∞
= ∑ x 1 (k ) 4 ∑ x 2 (m k)x (n
| {z } 3
m)5
k= ∞ m= ∞
=`
" #
∞ ∞
= ∑ x 1 (k ) ∑ x2 (`) x3 (n k `)
k= ∞ m= ∞
∞
= ∑ x1 (k) [x2 (n k ) x 3 (n k)] = x1 (n) [x2 (n) x3 (n)]
k= ∞
Distribution:
∞
x1 (n) [x2 (n) + x3 (n)] = ∑ x1 (k) [x2 (n k ) + x 3 (n k)]
k= ∞
∞ ∞
= ∑ x1 (k) x2 (n k) + ∑ x1 (k) x3 (n k)
k= ∞ k= ∞
= x 1 (n ) x 2 ( n ) + x 1 (n ) x 3 ( n )
Identity:
∞
x (n) δ (n n0 ) = ∑ x (k) δ (n n0 k) = x (n n0 )
k= ∞
% Commutative Property
[y1,ny1] = conv_m(x1,n1,x2,n2);
[y2,ny2] = conv_m(x2,n2,x1,n1);
ydiff = max(abs(y1-y2))
ydiff =
4.2633e-014
ndiff = max(abs(ny1-ny2))
ndiff =
0
% Associative Property
[y1,ny1] = conv_m(x1,n1,x2,n2);
[y1,ny1] = conv_m(y1,ny1,x3,n3);
[y2,ny2] = conv_m(x2,n2,x3,n3);
[y2,ny2] = conv_m(x1,n1,y2,ny2);
ydiff = max(abs(y1-y2))
12 S OLUTIONS M ANUAL FOR DSP USING M ATLAB A PRIL 98
ydiff =
6.8212e-013
ndiff = max(abs(ny1-ny2))
ndiff =
0
% Distributive Property
[y1,ny1] = sigadd(x2,n2,x3,n3);
[y1,ny1] = conv_m(x1,n1,y1,ny1);
[y2,ny2] = conv_m(x1,n1,x2,n2);
[y3,ny3] = conv_m(x1,n1,x3,n3);
[y2,ny2] = sigadd(y2,ny2,y3,ny3);
ydiff = max(abs(y1-y2))
ydiff =
1.7053e-013
ndiff = max(abs(ny1-ny2))
ndiff =
0
% Identity Property
n0 = fix(100*(rand(1,1)-0.5));
[dl,ndl] = impseq(n0,n0,n0);
[y1,ny1] = conv_m(x1,n1,dl,ndl);
[y2,ny2] = sigshift(x1,n1,n0);
ydiff = max(abs(y1-y2))
ydiff =
0
ndiff = max(abs(ny1-ny2))
ndiff =
0
(c) Note that the matrix H has an interesting structure. Each diagonal of H contains the same number. Such a matrix is
called a Toeplitz matrix. It is characterized by the following property
[H]i; j = [H]i j
(d) Note carefully that the first column of H contains the impulse response vector h (n) followed by number of zeros
equal to the number of x (n) values minus one. The first row contains the first element of h (n) followed by the same
number of zeros as in the first column. Using this information and the above property we can generate the whole
Topelitz matrix.
7. Problem P2.14:
The analytical solution to the convolution in (8a) is the exact answer. In the filter function approach of (8b), the
infinite-duration sequence x(n) is exactly represented by coefficients of an equivalent filter. Therefore, the filter solution
should be exact except that it is evaluated up to the length of the input sequence. The plots of this solution are shown in
Figure 2.9.
Problem P2.15
Analytical computation
3
2
ya(n)
−1
0 5 10 15 20 25 30 35 40 45 50
n
Filter output
3
2
yb(n)
−1
0 5 10 15 20 25 30 35 40 45 50
n