Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Difference equation:

To find impulse response:


• x = impseq(…), then apply y = filter(b,a,x)
• h = impz(b,a,n);

To find the response of given input x:


• y = filter(b,a,x)
• y = h* x → y = conv(x,h);

To sketch the pole-zero plot:


• zplane(b,a)

To find frequency respone:


• H = freqz(b,a,w); magH = abs(H); phaH = angle(H)

Note that:
FIR filter a=1

Example:

Given the following difference equation:


y(n) − y(n − 1) + 0.9y(n − 2) = x(n); ∀n
• Determine the impulse response h(n).

b = [1]; a = [1, -1, 0.9]; n = [-20:120];


h = impz(b,a,n);
subplot(2,1,1); stem(n,h);
title('Impulse Response using impz'); xlabel('n');
ylabel('h(n)')

x = impseq(0,-20,120); h1 = filter(b,a,x);
subplot(2,1,2); stem(n,h1);
title('Impulse Response using impseq and filter');
xlabel('n'); ylabel('h(n)')
• Calculate and plot the unit step response

x = stepseq(0,-20,120); s = filter(b,a,x);
subplot(2,1,1); stem(n,s)
title('Step Response'); xlabel('n');
ylabel('s(n)')
• Given x(n) = u(n) – u(n-10), determine the output:

x = stepseq(0,-20,120)-stepseq(10,-20,120);
y = filter(b,a,x);
subplot(2,1,2); stem(n,y)
title('System Response when x(n) = u(n) – u(n-
10)'); xlabel('n'); ylabel('y(n)')

• Sketch the pole-zero plot

zplane(b,a)
title('z plane');

• Is the system specified by h(n) stable?

Based on the pole-zero plot → stable


Or:
sum(abs(h)) %finite value
sum(abs(h1)) %finite value
%Find the poles
z = roots(a); magz = abs(z) %magz less than 1

• Plot magnitude and phase of H(ejω)

w = [0:1:500]*pi/500; H = freqz(b,a,w); magH =


abs(H); phaH = angle(H);
subplot(2,1,1);plot(w/pi,magH);grid
xlabel('frequency in pi units');
ylabel('Magnitude');
title('Magnitude Response')
subplot(2,1,2);plot(w/pi,phaH/pi);grid
xlabel('frequency in pi units'); ylabel('Phase in
pi units');
title('Phase Response')
MATLAB Assignment:
Causal LTI system has the following I/O equation:
y(n)= 3y(n-1) - 2y(n-2) + x(n) + x(n-1)
a. Determine impulse response h(n).
b. Plot pole-zeros diagram. Is the system stable.
c. Find the output if x(n)= (−2) n u ( n) .
d. Plot frequency response H(ejw).

Submit to elearning by Jan 26, 2021 (Tue)

You might also like