Vous êtes sur la page 1sur 40

Chapter 2.

Discrete-Time Signals and Systems


Gao Xinbo
School of E.E., Xidian Univ.
Xbgao@ieee.org
http://see.xidian.edu.cn/teach/matlabdsp/

Main Contents

Important types of signals and their operations


Linear and shift-invariant system

Easier to analyze and implement

The convolution and difference equation repres


entations
Representations and implementation of signal
and systems using MATLAB

Discrete-time signals

Analog and discrete signals


analog signal xa (t )
t represents any physical quantity, time in sec.
Discrete signal: discrete-time signal x(n)

N is integer valued, represents discrete instance


s in times
x(n) {x(n)} {, x(1), x(0), x(1),}

Discrete-time signal

In Matlab, a finite-duration sequence representation r


equires two vectors, and each for x and n.

Example:

x(n) {2,1,1,0,1,4,3,7}
n [3,2,1,0,1,2,3,4];
x [2,1,1,0,1,4,3,7];

Question: whether or not an arbitrary infinite-duration seq


uence can be represented in MATLAB?

Types of sequences

Elementary sequence for analysis purposes


1. Unit sample sequence

1, n 0
( n)
,0,0, 1,0,0,

0, n 0

Representation in MATLAB
1, n n0
(n n0 )
, n1 n n2 , n1 n0 n2
0, n n0

Function [x,n]=impseq(n0,n1,n2)
A: n=[n1:n2];

x = zeros(1,n2-n1+1); x(n0-n1+1)=1;

B: n=[n1:n2]; x = [(n-n0)==0]; stem(n,x,ro);

1
0.8

(n-n )
0

0.6

-3<n<3

0.4

n0=0

0.2
0
-3

-2

-1

0
n

2. Unit step sequence

1, n 0
u ( n)
,0,0, 1,1,1,

0, n 0

1, n n0
u (n n0 )
, n1 n n2 , n1 n0 n2
0, n n0
A: n=[n1:n2]; x=zeros(1,n2-n2+1); x(n0n1+1:end)=1;
B: n=[n1:n2]; x=[(n-n0)>=0];

3. Real-valued exponential sequence


x(n) a n , n; a R
For
Example:

x(n) (0.9) n , 0 n 10
n=[0:10]; x=(0.9).^n;
stem(n,x,ro)
1
0.8
0.6
0.4
0.2
0

10

4. Complex-valued exponential sequence

x ( n) e

( j 0 ) n

, n

Attenuation:
frequency in radians:
For Example: n=[0:10]; x=exp((2+3j)*n);

5. Sinusoidal sequence
x(n) cos(0 n ), n
Phase in radians
For Example:
n=[0:10];
x=3*cos(0.1*pi*n+pi/3)+2*sin(0.5*pi*n)

6. Random sequence

Rand(1,N)

Generate a length N random sequence whose elem


ents are uniformly distributed between [0,1]

Randn(1,N)

Generate a length N Gaussian random sequence w


ith mean 0 and variance 1. en [0,1]

7. Periodic sequence

A sequence x(n) is periodic if x(n)=x(n+N)


The smallest integer N is called the fundam
ental period
For example
A: xtilde=[x,x,x,x]
B: xtilde=x*ones(1,P); xtilde=xtilde(:); xtil
de=xtilde;
transposition

Operations on sequence

1. Signal addition

Sample-by-sample addition
{x1(n)}+{x2(n)}={x1(n)+x2(n)}

Function [y,n]=sigadd(x1,n1,x2,n2)
n=min(min(n1),min(n2)):
max(max(n1),max(n2));
y1=zeros(1,length(n)); y2=y1;
y1(find((n>=min(n1)) &
(n<=max(n1))==1))=x1;
y2(find((n>=min(n2)) &
(n<=max(n2))==1))=x2;

2. Signal multiplication

Sample-by-sample multiplication
Dot multiplication
{x1(n)}.{x2(n)}={x1(n) x2(n)}

Function [y,n]=sigmult(x1,n1,x2,n2)
n=min(min(n1),min(n2)) :
max(max(n1),max(n2));
y1=zeros(1,length(n)); y2=y1;
y1(find((n>=min(n1)) &
(n<=max(n1))==1))=x1;
y2(find((n>=min(n2)) &
(n<=max(n2))==1))=x2;

3. Scaling

a{x(n)}={ax(n)}

4. Shifting

y(n)={x(n-k)}
m=n-k; y=x;

5. folding

y(n)={x(-n)}
y=fliplr(x); n=-fliplr(n);

6. Sample summation
n2

x(n) x(n1 ) x(n2 )

n n1

ss = sum(x(n1:n2);
7. Sample production
n2

x(n) x(n1 ) x(n2 )

nn
1

sp = prod(x(n1:n2));

8. Signal energy

2
x
(
n
)
x
(
n
)

|
x
(
n
)
|

se = sum(x .* conj(x)); or
se = sum(abs(x) .^ 2);
9. Signal power

1
Px
N

N 1

2
|
x
(
n
)
|

n 0

Examples

Ex020100 composite basic sequences


Ex020200 operation on sequences
Ex020300 complex sequence generation
Ex020400 even-odd decomposition

Some useful results

Unit sample synthesis

Any arbitrary sequence can be synthesized as a weighted s


um of delayed and scaled unit sample sequence.
x ( n)

x(k ) (n k )

Even and odd synthesis

Even (symmetric): xe(-n)=xe(n)

Odd (antisymmetric): xo(-n)=-xo(n)

Any arbitrary real-valued sequence can be decomposed int


o its even and odd component: x (n)=xe(n)+ xo(n)

1
xe (n) [ x(n) x( n)]
2
1
xo (n) [ x(n) x(n)]
2
Function [xe, x0, m] = evenodd(x,n)
If any(imag(x) ~= 0)
error(x is not a real sequence);
End
m = -fliplr(n);
m1 = min([m,n]); m2 = max([m,n]); m=m1:m2;
nm = n(1)-m(1); n1 = 1:length(n);
x1 = zeros(1, length(m)); x1(n1+nm) = x; x = x1;
xe = 0.5 * (x + flipflr(x));
xo = 0.5*(x - fliplr(x));

The geometric series

A one-side exponential sequence of the form {an, n>=0}, w


here a is an arbitrary constant, is called a geometric series.

1
a 1 a , for | a | 1
n 0

Expression for the sum of any finite number of terms of th


N 1
e series
1 aN
n

a
n 0

1 a

, a

Correlations of sequences

It is a measure of the degree to which two sequences are si


milar. Given two real-valued sequences x(n) and y(n) of fin
ite energy,
Crosscorrelation

rx , y (l )

x ( n) y ( n l )

The index l is called the shift or lag


parameter.

Autocorrelation

rx , x (l )

x ( n) x ( n l )

The special case: y(n)=x(n)

Discrete Systems

Mathematically, an operation T[.]

y(n) = T [ x(n)]
x(n): excitation, input signal
y(n): response, output signal

Classification

Linear systems
Nonlinear systems

Linear operation L[.]

Iff L[.] satisfies the principle of superposition


L[a1 x1 (n) a2 x2 (n)] a1 L[ x1 (n)] a2 L[ x2 (n)]
a1 , a2 , x1 (n), x2 (n)

The output y(n) of a linear system to an arbitrary input x(n)

y (n) L[ x(n)] L

L[ (n k )] is

x(k ) (n k )

x(k ) L[ (n k )]

called impulse response, and is denoted by h(n,k)

y ( n)

x(k )h(n, k )

h(n,k): the time-varying impulse response

Linear time-invariant (LTI) system

A linear system in which an input-output pair is invariant to a shift n in tim


e is called a linear times-invariant system
y(n) = L[x(n)] --- y(n-k) = L[x(n-k)]

h(n, k ) L[ (n k )] h(n k )

The output of a LTI system is call a linear convolution sum

y (n) LTI [ x(n)]

x(k )k (n k ) x(n) * h(n)

An LTI system is completely characterized in the time domain by the impu


lse response h(n).

Properties of the LTI system

Stability

A system is said to be bounded-input bounded-output


(BIBO) stable if every bounded input produces a bound
ed output.
Condition: absolutely summable
BIBO Stability

| h(n) |

To avoid building harmful systems or to avoid burnout


or saturation in system operation

Properties of the LTI system

Causality

A system is said to be causal if the output at index n0 depen


ds only on the input up to and including the index n0
The output does not depend on the future values of the inpu
t
Condition: h(n) = 0, n < 0
Such a sequence is termed a causal sequence.
To make sure that systems can be built.

Convolution

Convolution can be evaluated in many different ways

If the sequences are mathematical functions, then we can an


alytically evaluate x(n)*h(n) for all n to obtain a functional
form of y(n)
Graphical interpretation, folded-and-shifted version
Matlab implementation

Function [y,ny]=conv_m(x,nx,h,nh)
nyb = nx(1)+nh(1); nye = nx(length(x))+nh(length(h));
ny = [nyb:nye];
n = conv(x,h)

Function form of convolution


x(n) u (n) u (n 10), h(n) (0.9) n u (n)
9

y (n) x(n) * h(n) 1 (0.9) n k u (n k )


k 0

Three different conditions under which u(n-k) can


be evaluated:
Case 1: n<0

% the nonzero values of x(n)and y(n) do not

overlap.

Case 2: 0<=n<9 % partially overlaps


Case 3: n>=9

% completely overlaps

Folded-and-shifted
Signals x=[x(1),x(2),x(3),x(4),x(5)]
System Impulse Response: h=[h(1),h(2)h(3),h(4)]
y=conv(x,h)
y(1)=x(1)*h(1); y(2)=x(1)*h(2)+x(2)*h(1)
y(3)=x(1)*h(3)+x(2)*h(2)+x(3)*h(1);
x(1),x(2),x(3),x(4),x(5)
h(4),h(3),h(2),h(1)
Note that the resulting sequence y(n) has a longer length than both the x(n)
and h(n) sequence.

Sequence correlations revisited

The correlation can be computed using the conv function if


sequences are of finite duration.

ryx (n)
rxx (n)

y (n) x(n k ) y (n) x((k n)) y (n) * x(n)

x(n) x(n k ) x(n) x((k n)) x(n) * x(n)

Example 2.8

The meaning of the crosscorrelation


This approach can be used in applications like radar signal process
ing in identifying and localizing targets.

Difference Equation

An LTI discrete system can also be described by a linear c


onstant coefficient difference equation of the form
N

k 0

m0

ak y (n k ) bm x(n m), n

If aN ~= 0, then the difference equation is of order N

It describes a recursive approach for computing the curren


t output,given the input values and previously computed o
utput values.
y ( n)

m 0

k 1

bm x(n m) a k y(n k )

Solution of difference equation

y(n) = yH(n) + yP(n)

Analytical approach using Z-transform will


be discussed in Chapter 4
Numerical solution with Matlab

Homogeneous part: yH(n)


Particular part: yP(n)

y = filter(b,a,x)

Example 2.9

Zero-input and Zero-state response

In DSP the difference equation is generally solved forward in t


ime from n=0. Therefore initial conditions on x(n) and y(n) ar
e necessary to determine the output for n>=0.
y ( n)

m 0

k 1

bm x(n m) a k y (n k ), n 0

Subject to the initial conditions:

{ y (n); N n 1} and {x(n); M n 1}


Solution
:

y (n) y ZI (n) y ZS (n)

Zero-input and Zero-state response

yZI(n): zero-input solution

A solution due to the initial conditions alone

yZS(n): zero-state solution

A solution due to input x(n) alone

Digital filter

Discrete-time LTI systems are also called digital filter.


Classification

FIR filter & IIR filter

FIR filter

Finite-duration impulse response filter


Causal FIR filter
y ( n)

bm x(n m)

m 0

h(0)=b0,,h(M)=bM
Nonrecursive or moving average (MA) filter
Difference equation coefficients, {bm} and {a0=1}
Implementation in Matlab: Conv(x,h); filter(b,1,x)

IIR filter

Infinite-duration impulse response filter


Difference equation N a y (n k ) x(n)

k 0

Recursive filter, in which the output y(n) is recursi


vely computed from its previously computed values
Autoregressive (AR) filter

ARMA filter

Generalized IIR filter


y ( n)

m 0

k 1

bm x(n m) a k y(n k ), n 0

It has two parts: MA part and AR part


Autoregressive moving average filter, ARMA
Solution

filter(b,a,x);

%{bm}, {ak}

Reference and Assignment

Textbook: pp1 to pp35


Chinese reference book: pp1 to pp18

,2001 1

Exercises:

Textbook: p2.1b,c; p2.2b,d; 2.5


Textbook: P2.12b, 2.15, 2.17b, 2.8

Vous aimerez peut-être aussi