Академический Документы
Профессиональный Документы
Культура Документы
LAB # 3 HANDOUT
1. DISCRETE SYSTEMS
y(n)=T[x(n)]
Discrete systems have different classifications based on the input and output
relation:
1.1 LINEARITY
The system is linear if it satisfies superposition principles.
x1(n) y1(n)
x2(n) y2(n)
A discrete system T[.] is a linear operator L[.] if and only if L[.] satisfies the
principle of superposition.
y(n)=L[x(n)]
x1(n) y1(n)
x1(n-n0) y1(n-n0)
1
EEE420 Lab Handout
An LTI system is BIBO stable if and only if its impulse response is absolutely
summable.
BIBO stability
n =
h( n) <
2. CONVOLUTION
y(n) =x(n)*h(n) or y ( n) = x (k )h(n k )
k =
Ex:
x(n)={ 3,11,7,0,-1,4,2 } , -3 n 3;
h(n)={ 2,3,0,-5,2,1 } , -1 n 4;
Determine the convolution y(n)=x(n)*h(n)
Solution:
Beginning point (first nonzero sample) of y(n) is given by n= -3+(-1) = -4, while
the end point (the last nonzero sample) is given by n = 3+4 = 7.
y ( n) = x(k )h(n k ) and
k =
for n=0 y(0)=0*4 + 3*2 + 11*-5 + 7*0 + 0*3 + -1*2 + 4*0 + 2*0= -51
for n=-1 y(-1)= 0*1 + 0*2 + 3*-5 + 11*0 + 7*3 + 0*2 + -1*0 + 4*0 + 2*0= 6
2
EEE420 Lab Handout
x (k )
12
10
-2
-3 -2 -1 0 1 2 3
h(k)
3
-1
-2
-3
-4
-5
-1 -0.5 0 0.5 1 1.5 2 2.5 3 3.5 4
h(-k )
3
-1
-2
-3
-4
-5
-4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 0.5 1
h(-1-k)
3
-1
-2
-3
-4
-5
-5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0
h(2-k )
3
-1
-2
-3
-4
-5
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 3
In matlab
>> y=conv(x,h);
The convolution function assumes that the two sequences begin at n=0.
3
EEE420 Lab Handout
>> x=[3,11,7,0,-1,4,2];
>> h=[2,3,0,-5,2,1];
>> y=conv(x,h);
y =
function [y,ny]=conv_m(x,nx,h,nh)
nyb=nx(1)+nh(1); nye=nx(length(x))+nh(length(h));
ny=[nyb:nye];
y=conv(x,h);
Command Window:
ny =
Hence,
y(n)= { }
3. CORRELATION
Ex:
x(n)={ 3,11,7,0,-1,4,2 } , -3 n 3;
and y(n)= x(n-2) + w(n)
where w(n) is Gaussian sequence with mean 0 and variance 1. Crosscorrelation
between y(n) and x(n)? ryx=?
4
EEE420 Lab Handout
% noise sequence 1
x = [3, 11, 7, 0, -1, 4, 2]; nx=[-3:3]; % given signal x(n)
[y,ny] = sigshift(x,nx,2); % obtain x(n-2)
w = randn(1,length(y)); nw = ny; % generate w(n)
[y,ny] = sigadd(y,ny,w,nw); % obtain y(n)=x(n-2)+w(n)
[x1,nx1] = sigfold(x,nx); % obtain x(-n)
[rxy,nrxy] = conv_m(y,ny,x1,nx1); % cross-correlation
subplot(2,1,1);stem(nrxy,rxy)
axis([-4,8,-50,250]);xlabel('lag variable l')
ylabel('rxy');title('Crosscorrelation: noise sequence 1')
%
% noise sequence 2
x = [3, 11, 7, 0, -1, 4, 2]; nx=[-3:3]; % given signal x(n)
[y,ny] = sigshift(x,nx,2); % obtain x(n-2)
w = randn(1,length(y)); nw = ny; % generate w(n)
[y,ny] = sigadd(y,ny,w,nw); % obtain y(n)=x(n-2)+w(n)
[x1,nx1] = sigfold(x,nx); % obtain x(-n)
[rxy,nrxy] = conv_m(y,ny,x1,nx1); % cross-correlation
subplot(2,1,2);stem(nrxy,rxy)
axis([-4,8,-50,250]);xlabel('lag variable l')
ylabel('rxy');title('Crosscorrelation: noise sequence 2')
Also, it should be noted that there is a function called xcorr for sequence
correlation computations.
>> xcorr(x,y) cross-correlation
Or
>> xcorr(x) auto-correlation
However, the xcorr function can not provide the timing information (as done by
conv_m). Because of this, we will use conv_m function.
4. DIFFERENCE EQUATION
5
EEE420 Lab Handout
Ex:
y(n) - y(n-1) + 0.9y(n-2) = x(n)
a) Calculate and plot the impulse response h(n) at n=-20.120
b) Calculate and plot the unit step response s(n) at n=-20.120
c)Is the system specified by h(n) stable?
Command window:
Part a)
a=[1,-1,0.9];b=1;
x=impseq(0,-20,120);n=[-20:120];
h=filter(b,a,x);
subplot(2,1,1);stem(n,h)
axis([-20,120,-1.1,1.1])
title('Impulse Response');xlabel('n');ylabel('h(n)')
Part b)
x=stepseq(0,-20,120);
s=filter(b,a,x);
subplot(2,1,2);stem(n,s)
axis([-20,120,-.5,2.5])
title('Step Response');xlabel('n');ylabel('s(n)')
Part c) stability h( n) <
>>sum(abs(h))