LAB # HANDOUT. DISCRETE SYSTEMS Mathematically, a discrete-time system (or discrete system for short ) is described as an operator T[.] that takes a sequence x(n) and transforms it into another sequence y(n)(called response). y(n)=t[x(n)] Discrete systems have different classifications based on the input and output relation:. LINEARITY The system is linear if it satisfies superposition principles. x(n) y(n) x(n) y(n) Then for linearity, αx(n) + βx(n) αy(n) + βy(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)]. TIME INVARIANCE x(n) x(n-n) y(n) y(n-n) A system which satisfies both of the conditions is called Linear Time-Invariant (LTI) system. The impulse response of an LTI system is given by h(n). x(n) h(n) y(n)
This system can be described as y(n) =x(n)*h(n) Or y(n) x(k )h(n k ) k. STABILITY A system is said to be bounded-input bounded output(bibo) stable if every bounded input produces a bounded output. x(n) < y(n) < An LTI system is BIBO stable if and only if its impulse response is absolutely summable.. CONVOLUTION BIBO stability n h(n) The convolution operation was introduced before to describe the response of an LTI system. Convolution can be evaluated in many different ways. If the sequences are mathematical functions, then we can analytically evaluate for all n to obtain a functional form of y(n). y(n) =x(n)*h(n) or y(n) x(k )h(n k ) k Ex: x(n)={,,7,,-,4, }, - n ; h(n)={,,,,, }, - n 4; Determine the convolution y(n)=x(n)*h(n) Solution: Beginning point (first nonzero sample) of y(n) is given by n= -+(-) =, while the end point (the last nonzero sample) is given by n = +4 = 7. y(n) x(k )h(n k ) and k for n= y()=*4 + * + * + 7* + * + -* + 4* + *= for n=- y(-)= * + * + * + * + 7* + * + -* + 4* + *= 6 for n= y()= * + 7* + * + -* + 4* + *= 4
x(k) 8 6 4 - - - - h(k) - - - - -.5.5.5.5.5 4 h(-k) - - - -.5 - -.5 - -.5 - -.5.5 h(--k) - - -.5 -.5 - -.5 - -.5 - -.5 h(-k) - - - - -.5 - -.5.5.5.5 In matlab >> y=conv(x,h); The convolution function assumes that the two sequences begin at n=.
>> x=[,,7,,-,4,]; >> h=[,,,,,]; >> y=conv(x,h); y = Because of this, we do not use this. We will use: M-file: function [y,ny]=conv_m(x,nx,h,nh) nyb=nx()+nh(); nye=nx(length(x))+nh(length(h)); ny=[nyb:nye]; y=conv(x,h); Command Window: >> x=[,,7,,-,4,]; nx=[-:]; >> h=[,,,,,]; nh=[-:4]; >> [y,ny]=conv_m(x,nx,h,nh) y = ny = Hence, y(n)= { }. CORRELATION and COVARIANCE Correlation is the measure of similarity between two sequences. R X,Y (n, n ) = E[X(n )Y(n )] = Y(l) X( l) crosscorrelation R X (n, n ) = E[X(n )X(n )] = X(l) X( l) autocorrelation 4
Covariance is a measure of how much two random variables change together. C X,Y (n, n ) = R X,Y (n, n ) m X (n )m Y (n ) crosscovariance C X (n, n ) = R X (n, n ) m X (n )m X (n ) autocovariance Correlation coefficient R X,Y(n) ρ X,Y (n) = R X ()R Y () Ex: x(n)={,,7,,-,4, }, - n ; and y(n)= x(n-) + w(n) where w(n) is Gaussian sequence with mean and variance. Crosscorrelation between y(n) and x(n)? R Y,X =? In matlab (command window): % noise sequence x = [,, 7,, -, 4, ]; [y,ny] = sigshift(x,nx,); w = randn(,length(y)); nw = ny; [y,ny] = sigadd(y,ny,w,nw); [x,nx] = sigfold(x,nx); [rxy,nrxy] = conv_m(y,ny,x,nx); nx=[-:]; % given signal x(n) % obtain x(n-) % generate w(n) obtain y(n)=x(n-)+w(n) % obtain x(-n) % cross-correlation subplot(,,);stem(nrxy,rxy) axis([,8,,5]);xlabel('lag variable l') ylabel('rxy');title('crosscorrelation: noise sequence ') % noise sequence x = [,, 7,, -, 4, ]; [y,ny] = sigshift(x,nx,); w = randn(,length(y)); nw = ny; [y,ny] = sigadd(y,ny,w,nw); [x,nx] = sigfold(x,nx); [rxy,nrxy] = conv_m(y,ny,x,nx); nx=[-:]; % given signal x(n) % obtain x(n-) % generate w(n) obtain y(n)=x(n-)+w(n) % obtain x(-n) % cross-correlation subplot(,,);stem(nrxy,rxy) axis([,8,,5]);xlabel('lag variable l') ylabel('rxy');title('crosscorrelation: noise sequence ') 5
Ex=sum(abs(x).^); %power in signals Ey=sum(abs(y).^); rhoxy=rxy/(sqrt(ex*ey)); %correlation coefficeients subplot(,,); stem(nrxy,rhoxy) axis([,8,-,]);xlabel('lag variable l') ylabel('rxy');title('correlation coefficient') EEE4 Lab Handout Also, it should be noted that there is a function called xcorr for sequence correlation computations. >> xcorr(x,y) cross-correlation >> xcorr(x) auto-correlation Also, it should be noted that there is a function called xcov for sequence correlation computations >> xcov(x,y) cross-covariance >> xcov(x) auto-covariance There is a function called corrcoef to find correlation coefficient >> corrcoef(x) correlation coefficient However, the xcorr function can not provide the timing information (as done by conv_m). Because of this, we will use conv_m function. EX: x=ones(,5); % define signal x y=ones(,7); % define signal Y [c,lags]=xcorr(x,x); %finding auto-correlation [c,lags]=xcorr(x,y); %finding cross-correlation figure subplot(,,) stem(lags,c) axis([-8 8 5]) %[Xmin,Xmax,Ymin,Ymax] subplot(,,) stem(lags,c) axis([-8 8 5]) x=[zeros(,5),,zeros(,5)]; % define signal x subplot(4,,), stem(x) y=.75*[zeros(,),x]+.*randn(,7); % define signal Y subplot(4,,), stem(y) [c lags]=xcov(x); %finding auto-covariance subplot(4,,), stem(lags,c) [c lags]=xcov(x,y); %finding cross-covariance subplot(4,,4), stem(lags,c) 6
4. DIFFERENCE EQUATION An LTI system can also be described by a linear constant coefficient difference equation. to solve this equation, we have filter function. y=filter(b,a,x) b=[b b bm]; for x values a=[a a.an]; for y values Ex: y(n) - y(n-) +.9y(n-) = x(n) a) Calculate and plot the impulse response h(n) at n=-. b) Calculate and plot the unit step response s(n) at n=-. c)is the system specified by h(n) stable? Command window: Part a) Part b) Part c) stability h(n) y(n)= bmx(n-m)- aky(n-k) m k a=[,-,.9];b=; x=impseq(,-,);n=[-:]; h=filter(b,a,x); subplot(,,);stem(n,h) axis([-,,-.,.]) title('impulse Response');xlabel('n');ylabel('h(n)') x=stepseq(,-,); s=filter(b,a,x); subplot(,,);stem(n,s) axis([-,,-.5,.5]) title('step Response');xlabel('n');ylabel('s(n)') >>sum(abs(h)) 7