Question 4.1:
% Program P4_1
% Evaluation of the DTFT clf; % Compute the frequency samples of the DTFT w = 0*pi:8*pi/511:2*pi;
M=input('Enter the value of M:'); num = (1/M)*ones(1,M); den = [1]; h = freqz(num, den, w);
% Plot the DTFT subplot(2,1,1) plot(w/pi,abs(h));grid title('Magnitude Spectrum |H(e^{j\omega})|') xlabel('\omega /\pi'); ylabel('Amplitude'); subplot(2,1,2) plot(w/pi,angle(h));grid title('Phase Spectrum arg[H(e^{j\omega})]') xlabel('\omega /\pi'); ylabel('Phase in radians');
M=3
M=7
M=9
Magnitude spectrum is even symmetric
Phase spectrum is odd symmetric
It represents the low pass filter. By increasing the value of M, it tends to approach ideal low pass filter
In question #2, our input contains two signals .A high pass and low pass. High pass signal is suppressed by the filter
Attenuation Testing
% Generate the input signal n = 0:100; x = cos(2*pi*0.07*n); % A low-frequency sinusoid
M =7;
% Compute the frequency samples of the DTFT w = -pi:2*pi/511:pi; num = (1/M)*ones(1,M); den = [1];
% Compute and plot the DTFT h = freqz(num, den, w); y=filter(num,den,x); subplot(2,1,1) plot(n,x);grid %title('Magnitude Spectrum |H(e^{j\omega})|')
%xlabel('\omega /\pi');
%ylabel('Amplitude');
subplot(2,1,2) plot(n,y);grid %title('Phase Spectrum arg[H(e^{j\omega})]')
%xlabel('\omega /\pi');
%ylabel('Phase in radians');
M=9
M=11
Attenuation increases by increasing the value of M
Testing of filter
M=9
Input was x=s1+s2; where s1 = cos(2*pi*0.05*n); % A low-frequency sinusoid s2 = cos(2*pi*0.47*n); % A high frequency sinusoid
High frequency signal is suppressed .
Question 4.2
% Program P4_2
% Evaluation of the DTFT clf; % Compute the frequency samples of the DTFT w = 0*pi:8*pi/511:1*pi; num =[0.15 0 -0.15] ; den = [1 -0.5 0.7]; h = freqz(num, den, w);
% Plot the DTFT subplot(2,1,1) plot(w/pi,abs(h));grid title('Magnitude Spectrum |H(e^{j\omega})|')