Professional Documents
Culture Documents
Solution To Homework 1
Solution To Homework 1
Homework Assignment #1
1.
Generate and plot the following sequences using the basic MATLAB signal
functions and the basic MATLAB signal operations discussed in Chapter 2.
(a) x1 (n) = 3 (n + 2) + 2 (n) (n 3) + 5 (n 7), 5 n 15.
n = -5:15; n1 = min(n); n2 = max(n);
x1 = 3*impseq(-2,n1,n2) + 2*impseq(0,n1,n2) - impseq(3,n1,n2) +
5*impseq(7,n1,n2);
figure; subplot(2,1,1); plot(n,0.*n); hold on; stem(n,x1);
xlabel('n'); ylabel('x1(n)'); axis([n1-1 n2+1 min(x1)-1
max(x1)+1]);
title('Sequence in Problem 2.1.1');
(b)
5 n 20.
(c)
(d)
shape.
n = 0:100; n1 = min(n); n2 = max(n);
x4 = exp(-0.05*n).*sin(0.1*pi*n+pi/3);
subplot(2,1,2); plot(n,0.*n); hold on; stem(n,x4);
xlabel('n'); ylabel('x4(n)'); axis([n1-1 n2+1 -1 +1]);
title('Sequence in Problem 2.1.7');
x1(n)
-2
-6
-4
-2
10
12
14
16
n
Sequence in Problem 2.1.3
10
x2(n)
-5
-5
10
n
15
20
x3(n)
5
0
-5
-10
-200
-150
-100
-50
0
n
50
100
150
200
x4(n)
0.5
-0.5
-1
0
2.
10
20
30
40
50
n
60
70
80
90
Let x(n) = {2, 4, -3, 1, -5, 4, 7}. Generate and plot the following sequences.
(a) x1 (n) = 2 x( n 3) + 3 x( n + 4) x(n).
(b) x2 (n) = 4 x(4 + n) + 5 x (n + 5) + 2 x (n).
(c)
(d)
x3 ( n) = x(n + 3) x (n 2) + x (1 n) x( n +1).
10 n 10.
% P2.4
clear;
n = -3:3;
x = [2 4 -3 1 -5 4 7];
% P2.4.1
% x1(n) = 2*x(n-3)+3*x(n+4)-x(n);
[x11,n11] = sigshift(x,n,3);
[x12,n12] = sigshift(x,n,-4);
[x13,n13] = sigadd(2*x11,n11,3*x12,n12);
[x1,n1] = sigadd(x13,n13,-1*x,n);
figure; subplot(2,1,1); plot(n1,0.*n1); hold on; stem(n1,x1);
100
x1(n)
10
0
-10
-8
-6
-4
-2
n
Sequence in Problem 2.4.2
60
x2(n)
40
20
0
-20
-8
-6
-4
-2
n
x3(n)
40
20
0
-20
-6
-4
-2
n
Sequence in Problem 2.4.4
60
x4(n)
40
20
0
-10
-5
0
n
10