实用
Name: Section:
Laboratory Exercise 2
DISCRETE-TIME SYSTEMS: TIME-DOMAIN REPRESENTATION
2.1
SIMULATION OF DISCRETE-TIME SYSTEMS
Project 2.1 The Moving Average System
A copy of Program P2_1 is given below: % Program P2_1
% Simulation of an M-point Moving Average Filter % Generate the input signal n = 0:100;
s1 = cos(2*pi*0.05*n); % A low-frequency sinusoid s2 = cos(2*pi*0.47*n); % 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: Q2.1
The output sequence generated by running the above program for M = 2 with x[n] =
s1[n]+s2[n] as the input is shown below.
The component of the input x[n] suppressed by the discrete-time system simulated by this program is – s2
Q2.2
Program P2_1 is modified to simulate the LTI system y[n] = 0.5(x[n]–x[n–1]) and process the input x[n] = s1[n]+s2[n] resulting in the output sequence shown
below:
s3=cos(2*pi*0.05*(n-1)); s4= cos(2*pi*0.47*(n-1)); z=s3+s4;
y = 0.5*(x-z);
文档
实用
The effect of changing the LTI system on the input is -
Project 2.2 (Optional) A Simple Nonlinear Discrete-Time System
A copy of Program P2_2 is given below: % Program P2_2 % Generate a sinusoidal input signal clf;
n = 0:200;
x = cos(2*pi*0.05*n);
% 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 generate the output signals:
The output signals generated for each of the above input signals are displayed below:
The output signals depend on the frequencies of the input signal according to the following rules:
This observation can be explained mathematically as follows:
Project 2.3
Linear and Nonlinear Systems
A copy of Program P2_3 is given below: % Program P2_3
文档
实用
% Generate the input sequences clf;
n = 0:40; a = 2;b = -3;
x1 = cos(2*pi*0.1*n); x2 = cos(2*pi*0.4*n); x = a*x1 + b*x2;
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 = a*y1 + b*y2;
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: Q2.7
The outputs y[n], obtained with weighted input, and yt[n], obtained by combining the two outputs y1[n] and y2[n] with the same weights, are shown below along with the difference between the two signals:
文档