%------------------------------------------------------------------------------
% Amine Faridi (29061780)
% EE-416
% Project#1
%------------------------------------------------------------------------------
A=[0.025,-0.07,0.05,-0.02];% This are the coefficient of the numerator
B=[1,1.5,1.75,1.02,0.4];%This are the coefficients of the denomenator
[zeross, poles]=residuez(A,B)%use this function to get zeross and poles, 
% I named it zeross so it doesn't confuse me with zeros, the matrix of zeros
subplot(2,2,1);
zplane(zeross,poles)%this is to plot the poles and the zeros and they are 
% inside the circle, that is what answer question 5.
f=0:0.001:0.4;%frequency decided to range it between 0 and 0.4
z=exp(-j*pi*f./0.4);%This to define z, we added - sign to avoid confusion in the next step
Hd=(0.025-0.07*z+0.05*z.^2-0.02*z.^3)./(1+1.5*z+1.75*z.^2+1.02*z.^3+0.4*z.^4);
amd=abs(Hd);%This is the amplitude of the frequency response
agd=angle(Hd);% angle of frequency response
subplot(2,2,2);
plot(amd);
subplot(2,2,3);
plot(agd);
% question # 5, the poles and zeros are inside the circle that makes the filter stable.
