










































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
SOLUTION Laboratory Exercise Material Type: Notes; Class: Digital Signal Processing; Subject: Electrical and Computer Engineering; University: United Arab Emirates University; Term: Forever 1989;
Typology: Study notes
1 / 50
This page cannot be seen from the preview
Don't miss anything!











































Project 2.1 The Moving Average System
% Program P2_ % Simulation of an M-point Moving Average Filter % Generate the input signal n = 0:100; s1 = cos(2pi0.05n); % A low-frequency sinusoid s2 = cos(2pi0.47n); % A high frequency sinusoid x = s1+s2; % Implementation of the moving average filter M = input('Desired length of the filter = '); num = ones(1,M); y = filter(num,1,x)/M; % Display the input and output signals clf; subplot(2,2,1); plot(n, s1); axis([0, 100, -2, 2]); xlabel('Time index n'); ylabel('Amplitude'); title('Signal #1'); subplot(2,2,2); plot(n, s2); axis([0, 100, -2, 2]); xlabel('Time index n'); ylabel('Amplitude'); title('Signal #2'); subplot(2,2,3); plot(n, x); axis([0, 100, -2, 2]); xlabel('Time index n'); ylabel('Amplitude'); title('Input Signal'); subplot(2,2,4); plot(n, y); axis([0, 100, -2, 2]); xlabel('Time index n'); ylabel('Amplitude'); title('Output Signal'); axis;
Answers:
Time index n
Amplitude
Signal #
Time index n
Amplitude
Signal #
Time index n
Amplitude
Input Signal
Time index n
Amplitude
Output Signal
% Program Q2_ % Modification of P1_1 to convert it to a high pass filter % Generate the input signal n = 0:100; s1 = cos(2pi0.05n); % A low-frequency sinusoid s2 = cos(2pi0.47n); % A high frequency sinusoid x = s1+s2; % Implementation of high pass filter M = input('Desired length of the filter = '); % By comparing eq. (2.13) to (2.3), you can see that "num" % actually contains the impulse response (times the constant % M). What we are actually doing in Q2.2 is multiplying the % impulse response of the low pass filter in P2_1 by the % sequency (-1)^n. This shifts the low pass frequency
Q2.3 Program P2_1 is run for the following values of filter length M and following values of the fre-
0 50 100
0
1
2
Time index n
Amplitude
Signal #
0 50 100
0
1
2
Time index n
Amplitude
Signal #
0 50 100
0
1
2
Time index n
Amplitude
Input Signal
0 50 100
0
1
2
Time index n
Amplitude
Output Signal
0 50 100
0
1
2
Time index n
Amplitude
Signal #
0 50 100
0
1
2
Time index n
Amplitude
Signal #
0 50 100
0
1
2
Time index n
Amplitude
Input Signal
0 50 100
0
1
2
Time index n
Amplitude
Output Signal
0 50 100
0
1
2
Time index n
Amplitude
Signal #
0 50 100
0
1
2
Time index n
Amplitude
Signal #
0 50 100
0
1
2
Time index n
Amplitude
Input Signal
0 50 100
0
1
2
Time index n
Amplitude
Output Signal
Time index n
Amplitude
Input Signal
Time index n
Amplitude
Output Signal
The results of Questions Q2.1 and Q2.2 from the response of this system to the swept-
Project 2.2 (Optional) A Simple Nonlinear Discrete-Time System
% Program P2_ % Generate a sinusoidal input signal clf; n = 0:200; x = cos(2pi0.05n); % Compute the output signal x1 = [x 0 0]; % x1[n] = x[n+1] x2 = [0 x 0]; % x2[n] = x[n] x3 = [0 0 x]; % x3[n] = x[n-1] y = x2.x2-x1.*x3; y = y(2:202); % Plot the input and output signals subplot(2,1,1) plot(n, x) xlabel('Time index n');ylabel('Amplitude'); title('Input Signal') subplot(2,1,2) plot(n,y) xlabel('Time index n');ylabel('Amplitude'); title('Output signal');
Answers:
Q2.5 The sinusoidal signals with the following frequencies as the input signals were used to
0 20 40 60 80 100 120 140 160 180 200
0
1
2
Time index n
Amplitude
Output Signal
The output signals depend on the frequencies of the input signal according to the following
2
2 2
2 2
2
2
2
Project 2.3 Linear and Nonlinear Systems
% Program P2_ % Generate the input sequences clf; n = 0:40; a = 2;b = -3; x1 = cos(2pi0.1n); x2 = cos(2pi0.4n); x = ax1 + bx2; num = [2.2403 2.4908 2.2403]; den = [1 -0.4 0.75]; ic = [0 0]; % Set zero initial conditions y1 = filter(num,den,x1,ic); % Compute the output y1[n] y2 = filter(num,den,x2,ic); % Compute the output y2[n] y = filter(num,den,x,ic); % Compute the output y[n] yt = ay1 + by2; d = y - yt; % Compute the difference output d[n] % Plot the outputs and the difference signal subplot(3,1,1) stem(n,y); ylabel('Amplitude'); title('Output Due to Weighted Input: a \cdot x_{1}[n] + b \cdot x_{2}[n]'); subplot(3,1,2) stem(n,yt); ylabel('Amplitude'); title('Weighted Output: a \cdot y_{1}[n] + b \cdot y_{2}[n]'); subplot(3,1,3) stem(n,d); xlabel('Time index n');ylabel('Amplitude'); title('Difference Signal');
Answers:
Amplitude
Output Due to Weighted Input: a (^) ⋅ x 1 [n] + b (^) ⋅ x 2 [n]
Amplitude
Weighted Output: a (^) ⋅ y 1 [n] + b (^) ⋅ y 2 [n]
x 10
Time index n
Amplitude
Difference Signal
Q2.8 Program P2_3 was run for the following three different sets of values of the weighting
0 5 10 15 20 25 30 35 40
0
200
Amplitude
Output Due to Weighted Input: a (^) ⋅ x 1 [n] + b (^) ⋅ x 2 [n]
0 5 10 15 20 25 30 35 40
0
200
Amplitude
Weighted Output: a (^) ⋅ y 1 [n] + b (^) ⋅ y 2 [n]
0 5 10 15 20 25 30 35 40
0
5
x 10-
Time index n
Amplitude
Difference Signal
0 5 10 15 20 25 30 35 40
0
20
Amplitude
Output Due to Weighted Input: a (^) ⋅ x 1 [n] + b (^) ⋅ x 2 [n]
0 5 10 15 20 25 30 35 40
0
50
Amplitude
Weighted Output: a (^) ⋅ y 1 [n] + b (^) ⋅ y 2 [n]
0 5 10 15 20 25 30 35 40
0
50
Time index n
Amplitude
Difference Signal
Q2.10 Program P2_3 was run with nonzero initial conditions and for the following three different sets
Amplitude
Output Due to Weighted Input: a (^) ⋅ x 1 [n] + b (^) ⋅ x 2 [n]
Amplitude
Weighted Output: a (^) ⋅ y 1 [n] + b (^) ⋅ y 2 [n]
Time index n
Amplitude
Difference Signal
Based on these plots we can conclude that the system with nonzero initial conditions and
y 1 [n]
y 2 [n]
y (^) t[n]
Amplitude
Output Due to Weighted Input: a (^) ⋅ x 1 [n] + b (^) ⋅ x 2 [n]
Amplitude
Weighted Output: a (^) ⋅ y 1 [n] + b (^) ⋅ y 2 [n]
Time index n
Amplitude
Difference Signal