Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
SIGNAL PROCESSING]
Polytechnic University of the Philippines
College of Engineering
ELECTRONICS AND COMMUNICATIONS ENGINEERING
3rd floor, CEA bldg., NDC Campus, Anonas St., Sta. Mesa, Manila
LABORATORY ACTIVITY # 2
In
Signature: _____________________________________________
To:
Instructor: ____________________________________________
Rating: ______________
Date: _________________
Instructor Comments:
x1 [ n]
and
y1 [ n ]
and
y2 [ n ]
Eq. (2.1)
y [ n ] = y 1 [ n ] + y 2 [ n ]
The preceding equation is known as the superposition property of a linear system. If
this a system does not satisfy this equation for at least one set of nonzero values of
and , or one set of nonzero input sequences
x1 [ n]
and
x 2 [ n ] , then the
system is nonlinear.
D2.2 Time Invariance
For a time-invariant or shift-invariant discrete-time system, if
response to an input
y1 [ n ]
is the
is simply
y [ n ] = y 1 [ nn0 ]
where
is any positive or negative integer. If the above relation does not hold
for at least one input sequence and its corresponding output sequence, the system
is time-varying.
D2.3 Linear Time-Invariant Discrete-Time System
A linear time-invariant (LTI) discrete-time system satisfies both the linearity and the
time-invariance properties.
D2.4 Causality
If
y1 [ n ]
inputs
y2 [ n ]
and
u1 [ n ]
u2 [ n ] , respectively, then
and
u1 [ n ] =u2 [ n ]
for
n< N
y1 [ n ]= y2 [ n ]
for
n< N .
y [n ]
is also a
|x [ n ]|< B x
Then the corresponding output
y [n ]
| y [ n ]|<B y
where
Bx
and
By
n ,
n ,
{ [n ]}
{h [ n ] }
{ [ n] }
, denoted as
{ s [ n] }
h [ n]
response
y [n ]
to an input signal
x[n]
is given by
Eq. (2.3)
y [ n ] = h [ k ] x [ nk ] ,
k=
which can be alternatively written as
Eq. (2.4)
y [ n ] = h [ nk ] x [ k ]
k=
by a simple change of variables. This sum is called the convolution sum of the
sequences
x[n]
and
Eq. (2.5)
y [ n ] =h [ n ] x [ n ]
where the symbol
h [ n]
h2 [ n ] , respectively, is given by
Eq. (2.6)
h [ n ] =h1 [ n ] h2 [ n ]
If the two LTI systems in the cascade connection are such that
Eq. (2.7)
h1 [ n ] h2 [ n ] = [ n ]
then the LTI system
h2 [ n ]
h1 [ n ]
and vice-versa.
Cascade Connection
Polytechnic University of the Philippines | College of Engineering
h1 [ n ]
{h [ n ] }
|h [ n ]|<
n=
{h [ n ] }
h [ k ] =0
for
k <0
k=0
k=0
d k y [ nk ] = pk x [ nk ]
where
and
x[n]
{d k }
and
and
y [n ]
{ pk }
(N, M), which is the order of the difference equation characterizing the system.
If the system is causal, we can rewrite the preceding equation as follows:
Eq. (2.11)
N
M
dk
p
y [ n ] =
y [ nk ] + k x [ nk ]
k=1 d 0
k=0 d 0
provided
x[n]
d 0 0 . The output
y [n ]
n n0
knowing
y [ n01 ] , y [ n 02 ] , , y [ n0N ] .
h [ n]
system. The causal system of the preceding equation represents an FIR system if
d k =0 for
1
y [ n ] = ( x [ n ] + x [ n1 ] + x [ n2 ] )
3
y [n ]=
1
M
M 1
x [ nk ]
k=0
which defines a causal M-point smoothing FIR filter. This system is also known as a
moving average filter. We illustrate its use in filtering high-frequency components
from a signal composed of a sum of several sinusoidal signals.
% Program P2_1
% Simulation of an M-point Moving Average Filter
% Generate the input signal
clf;
n = 0: 100;
Polytechnic University of the Philippines | College of Engineering
y [n ]
a signal
x[n] :
Eq. (2.14)
Polytechnic University of the Philippines | College of Engineering
y [ n ] =x [n] x [ n1 ] x [ n+1 ]
In this activity you will generate the output
types of the input
x[n]
y [n ]
x[n]
composed of a sum of two sinusoidal sequences and simulate the LTI system of EQ.
(2.14) to generate y [ n ] .
% 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 (Output signal);
Tasks & Questions:
TQ2.5 Use sinusoidal signals with different frequencies as the input signals and
compute the output signal for each input. How do the output signals depend on the
frequencies of the input signal? Can you verify your observation mathematically?
TQ2.6 Use sinusoidal signals of the form
x [ n ]=sin ( n ) + K
y [n ]
depend on the DC
value K?
Activity 2.3 Linear and Nonlinear Systems
We now investigate the linearity property of causal system. Consider the system
given by
Eq. (2.15)
x 2 [ n ] , and
x [ n ]=a x 1 [ n ] +b x 2 [ n ] , and to
y1 [ n ] ,
y 2 [ n ] , and
y [n ]
.
% 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');
Tasks & Questions:
TQ2.7 Run Program P2 3 and compare y[n] obtained with weighted input with yt[n]
obtained by combining the two outputs y1[n] and y2[n] with the same weights. Are
these two sequences equal? Is this system linear?
TQ2.8 Repeat TQ2.7 for three different sets of values of the weighting constants, a
and b, and three different sets of input frequencies.
TQ2.9 Repeat TQ2.7 with nonzero initial conditions.
TQ2.10 Repeat TQ2.8 with nonzero initial conditions.
Polytechnic University of the Philippines | College of Engineering
10
11
12
13
S ( K )= |h [ n ]|
n=0
for increasing values of K, and checks the value of |h[K]| at each iteration step. If
the value of |h[K]| is smaller than 106, then it is assumed that the sum S(K) of Eq.
(2.21) has converged and is very close to S().
% Program P2_8
% Stability test based on the sum of the absolute values of the impulse response
samples
clf;
num = [1 -0.8]; den = [1 1.5 0.9];
N = 200;
h impz(num, den, N+1);
parsum = 0;
for k = 1: N+1;
parsum = parsum + abs(h(k));
if abs(h(k)) < 10^(-6), break, end
end
% Plot the impulse response
n = 0: N; stem (n, h) xlabel (Time index n); ylabel (Amplitude);
% Print the value of abs (h(k))
disp (Value =); disp (abs(h(k)));
Tasks & Questions:
Polytechnic University of the Philippines | College of Engineering
14
x [ n ]=cos
% Program P2_9
% Generate the input sequence
clf;
n = 0:299;
x1 = cos(2*pi*10*n/256);
x2 = cos(2*pi*100*n/256);
x = x1+x2;
% Compute the output sequences
num1 = [0.5 0.27 0.77];
y1 = filter (num1, 1, x); % Output of System No. 1
den2 = [1 -0.53 0.46];
num2 = [0.45 0.5 0.45];
y2 = filter (num2, den2, x); % Output of System No. 2
% Plot the output sequences
Polytechnic University of the Philippines | College of Engineering
15
16