% EE-3221 Digital Signal Processing
% 24 January 2020
% Dr. Prust <prust@msoe.edu>

% Demonstration of MATLAB tools for discrete-time LTI System analysis

close all
clear all

%% Specify system in terms of b and a coefficient vectors
b = [1 0 -1];       % "x" coefficients in diff eq
a = [1 0 -0.81];    % "y" coefficients in diff eq

%% Get partial fraction expansion
[R,p,C] = residuez(b,a)

%% Get pole-zero plot
figure
zplane(b,a)
set(gca,'fontsize',14)

%% Get impulse response
figure
impz(b,a)
set(gca,'fontsize',14)

%% Get frequency response
omega = linspace(0,pi,1000);
H = freqz(b,a,omega);
figure
subplot(2,1,1)
plot(omega,abs(H))
set(gca,'fontsize',14)
grid on
xlabel('\Omega')
ylabel('|H(e^{j\Omega})|')
title('Magnitude Response')
subplot(2,1,2)
plot(omega,angle(H))
set(gca,'fontsize',14)
grid on
xlabel('\Omega')
ylabel('\angle H(e^{j\Omega})')
title('Phase Response')
