Activity in Difference Equation
Activity in Difference Equation
k)
ak y(n=
=
k 0=
m 0
x(n m),
(1)
N
eU
Cp
E
y ( n)
=
m x ( n m) ak y ( n k )
=
m 0=
k 1
AD
To compute and plot impulse response, OCTAVE provides the function impz.
When invoked by
h = impz(b,a,n);
it computes samples of the impulse response of the filter at the sample indices
given in n with numerator coefficients in b and denominator coefficients in a.
When no output arguments are given, the impz function plots the response in the
current figure window using the stem function.
SAMPLE EXERCISES 1
Ec
y (n)= y (n 1) + 2 y (n 2) + x(n 2)
given that
=
x(n) 4 cos( n=
8), y (0) 1=
and y (1) 1.
nakz.713@gmail.com
Solution:
N
eU
Cp
E
y=[1 1];
x(1)=4;
x(2)=4*cos(pi/8);
for n = 3:11
n1= n-1
x(n) = 4*cos(pi*n1/8);
y(n) = y(n-1) + 2*y(n-2) + x(n-2);
end;
stem(y);
xlabel(n);
ylabel(y(n));
title(system output y(n));
SAMPLE EXERCISES 2
y (n) y (n 1) + 0.9 y (n =
1) x(n); n
AD
Octave Script
>>
>>
>>
TASK 1
for b.
x = stepseq(0,-20,120); s = filter(b,a,x);
subplot(2,1,2); stem(n,s)
title(Step Response); xlabel(n); ylabel(s(n))
Ec
y ( n) =
0.5 y (n 1) + 0.25 y (n 2) =x(n) + 2 x(n 1) + x(n 3)
a. Using the filter function, compute and plot the impulse and step response
of the system over 0 n 100 .
b. If the input to this system is x(n) =
[5 + 3cos(0.2 n) + 4sin(0.6 n)] u (n) ,
determine the response y (n) over 0 n 200 using the filter function.
nakz.713@gmail.com