[go: up one dir, main page]

0% found this document useful (0 votes)
26 views4 pages

Module3 Part2

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 4

Module -3 (Discrete Time Domain Analysis) –Part 2

Method 1: Solving Difference equation using Iterative procedure :

Finding Total Response:


Ex: Given the difference equation, y[n+2] – y[n+1] + 0.24y[n] = x[n+2] – 2x[n+1] and with initial
conditions : y[-1] = 2 ; y[-2] = 1, with x[n] = n (starting at n = 0)
Following is the MATLAB code:
n = [-2:10]'; % defining the discrete time range for the solution
y = [1 ; 2 ; zeros(length(n) -2 , 1)]; % predefining the output array with first two elements are initial
conditions and subsequent elements are zeros
x=[ 0; 0 ; n(3 : end) ]; % defining the input array with first two entries corresponds to the time
instants -2 and -1
for k = 1 : length(n) -2 % Iterative computation starts here
y(k+2) = y(k+1) - 0.24*y(k) + x(k+2) - 2*x(k+1);
end;
% NOTE : when k = 1, y(3) value is computed indicating the first member of the solution. Since,
y(1) and y(2) have already assigned with initial conditions.
stem(n , y , 'k') % sketch of the solution including the initial conditions.
O/P -----> y = [1.0000 2.0000 1.7600 2.2800 1.8576 0.3104 -2.1354 - 5.2099 - 8.6974 -
12.4470 -16.3597 -20.3724 -24.4461]
▪ For finding the zero input response, do not consider the feed forward coefficients (terms
corresponding to the coefficients of x[n] and its advance operations), in the difference equation. OR
define the input array as zeroes
▪ For finding the zero state response, define the initial conditions as zeroes
▪ For finding the impulse response, define the input array as impulse and initial conditions as zeroes.
i.e. x=[ 0; 0 ; 1 ; zeros(length(n)-3 , 1)];

Method 2: Solving Difference equation using “filter” command in MATLAB:


MATLAB’s filter command provides an efficient way to evaluate the system response to a constant
coefficient (time-invariant) linear difference equation represented in delay form as
𝑵 𝑵

∑ 𝒂𝒌 𝒚[𝒏 − 𝒌] = ∑ 𝒃𝒌 𝒙[𝒏 − 𝒌]
𝒌=𝟎 𝒌=𝟎
Filter requires three input arguments:
a length N+1 vector of feed forward coefficients [bo,b1,b2,…bN]

1|Page
a length N+1 vector of feedback coefficients [ao,a1,a2,…aN] and
an input vector.
Optional 4th argument: initial state of the system should be appropriately inserted

Finding Impulse Response:


For the same above example, following is the MATLAB code:
N = 2; b = [1 -2 0]; a = [1 -1 0.24]; %defining difference equation
n = [0 : 30]' ; delta = inline('n == 0','n'); %defining impulse function
h = filter(b,a,delta(n));
stem(n,h)
Result: h = {1 -1 -1.24 -1 -0.702 -0.462 -0.294 -0.183 -0.1123 .....}
NOTE : ‘filter’ function gives first N (i.e. order of system) values of the solution as auxiliary
conditions, which is generally counted from running variable n = 0 to N-1. Here, first two values {1
and -1} in above result are considered as auxiliary conditions of the solution.

Finding Zero –State Response:


For the same above example, following is the MATLAB code:
N = 2; b= [1 -2 0]; a= [1 -1 0.24]; %defining difference equation
n=[0:30]'; x = inline(' n ',' n ') %defining input function
ys= filter(b,a,x(n));
stem(n,ys)
Result : ys = {0, 1, 1, -0.24, -2.48, -5.42, -8.82, -12.5258 . .......}
NOTE : “filter” function can’t be used in MATLAB to find the ZIR of the difference equation, as the
initial conditions can’t be accommodated directly. One may use the iterative method discussed above
and it may be added to ZSR to get the total response.

Method 3 : Convolution of two signals using ‘conv’ command


Case 1): Convolution of two finite-duration discrete time signals is accomplished by using the conv
command.
“Conv” command does not give the output with the region of support in the time axis.
Eg: 1) (u[n] - u[n-4) * (u[n] - u[n-4)
>> conv( [1 1 1 1] , [1 1 1 1] )
O/P ----> 1 2 3 4 3 2 1
Regions of support in time axis is (0 ≤ n ≤ 6) (7 elements = 4 + 4 - 1)
2) (u[n+4] - u[n) * (u[n] - u[n-4)
>> conv( [1 1 1 1] , [1 1 1 1] )

2|Page
O/P ----> 1 2 3 4 3 2 1
Regions of support in time axis is (- 4 ≤ n ≤ 2) (graphically supported)
The region of support for thus obtained output may be comprehended by the width property.

Case 2): In general, the conv command should be carefully used to convolve infinite – duration signals.
Conv command can correctly compute a portion of such infinite duration signals.

By passing the first N samples of each signal, conv command returns a length (2N - 1) sequence. The
first N samples are computed correctly; the remaining N-1 samples are wrong results.

For the difference equation mentioned in the above example, the impulse response (calculated
analytically) of the system is h[n] = {-7 (0.6)n + 8 (0.4)n } u[n], hence by defining the inline function
calling it with n = [0 : 30] ' as:
>> h = inline('(-7*0.6.^n+8*0.4.^n).*(n>=0)','n');
>> x = inline(' n ',' n ');
>> ytc= conv(h(n),x(n));
>> stem ( [0:60] , ytc ,'k') Compare the result with earlier method.

In the result, 0 ≤ n ≤ 30, output samples are correctly computed. The remaining 31 ≤ n ≤ 61 output
sample values are incorrectly computed. Theoretically, the output envelope should continue to grow as
n tends to infinity, not decay. If “conv” command is used to convolve infinite – duration signals,
normally incorrect values should be omitted and are not used for display as:
>> stem(n,ytc(0:30),'k') will be identical to the earlier result.

Method 4 : Convolution of two signals : (using Graphical Method)


Try to modify the MATLAB code to convolve two discrete time signals graphically and use it. (Refer
the MATLAB E code discussed in Module 3 part 1).
Hint: one may use “stem” instead of plot. Also, stem sketches only one signal in one axis. One may
use many subplots to achieve this. And Increment considered is 1.
In this case, irrespective of the signal duration, finite or infinite, one can get the output results with
the regions of support in time axis. This method does give the output with the region of support in the
time axis.

3|Page
Exercises

For all the following exercises of A) to E), comment (where ever applicable) on the Nature
(characteristic polynomial, characteristic roots, characteristic modes), stability, and find the time
constant (in terms of sample count) of the system. Sketch the output responses and comment on the
nature of the responses (belongs to which class of signal model). Comment on the cut-off frequency
and filtering action (by suitably changing the forcing function frequency). {EXPECTATION IS THAT
HAVING UNDERSTOOD THE SAME IN CONTINUOUS_TIME, SAME CAN BE
INTERPRETED HERE WITH MINOR DIFFERENCE}

A) Solve the following difference equations, to find the Impulse Response, Zero –Input Response,
Zero–State Response and Total Response. Try to get the results iteratively (20 samples) and also
using filter (as applicable) command.
1) y[n+2] –0.6 y[n+1] + 0.16y[n] = 0 with y[-1] = -25 ; y[-2] = 0
2) y[n+2] +3 y[n+1] + 2y[n] = x[n+2] +3x[n+1] +3x[n] with x[n] = (3)nu[n], y[-1] = 3 ; y[-2] = 2
3) y[n] +2 y[n-1] + y[n-2] = 2x[n] -x[n-1] with x[n] = (3)-nu[n], y[-1] = 2 ; y[-2] = 3
4) y[n+3] –1.6 y[n+2] + 0.8y[n+1] +0.02y[n] = x[n] with x[n] = u[n], y[-1] = 1 ; y[-2] = 2 and y[-3] =3

B) Consider the discrete time system y[n] + y[n-1] +0.25 y[n-2] = 3 x[n-8]. Find the zero input
response, if y[-1] = 1 ; y[-2] = 1

C) Find the unit impulse response h[n] and hence find ZSR for the systems specified by the following
difference equations: Try to get the results using graphical convolution (Method 4) AND using
“conv” (method 3) functions and compare.
1) y[n+1] + 2y[n] =x[n] with x[n] = 2n u[n-1]
2) y[n] + 2y[n-1] =x[n] with x[n] = 3n+2u[n+1]
3) (E2-6E+9)y[n] = Ex[n] with x[n] = (3)-nu[n]
4) y[n] - 6 y[n-1] + 25y[n-2] = 2x[n] -4x[n-1] with x[n] = n u[n]

D) Find the zero state response of the LTID system, whose following unit impulse response h[n] and
input x[n].
1) h[n] = (-2)nu[n-1] ; x[n] = e-nu[n+1]
2) h[n] = ½{δ[n-2]-(-2)n+1 }u[n-3] ; x[n] = 3n-1u[n+2]
3) h[n] = {(2)n-2 +3(-5)n+2 }u[n-1] ; x[n] = 3n+2u[n+1]
4) h[n] = 3(n-2)(2)n-3 u[n-4] ; x[n] = 3-n+2 u[n+3]
 
5) h[n] = (3)n cos  n − 0.5  u[n] ; x[n] = 2n u[n-1]
3 
E) Use classical method, to solve the equations given in exercise A), and compare the results with the
iterative methods.

4|Page

You might also like