Example-1 symmetric rectangular pulse is given by
x(n) = 1 −N ≤ n ≤ N
0 otherwise
Determine the discrete-time Fourier transform (DTFT) for N = 2, 5, 10, 15. Scale the DTFT
so that X(ej0) = 1. Plot the normalized magnitude response of the DTFT over [−π, π]. Study
these plots and comment on their behavior as a function of N.
Solution: First of all solve the function mathematically. Evaluate magnitude |X(e^jw)| and phase spectrum <X(e^jw).
clc; clear all; close all;
w=-pi:0.01:pi;
N=[2 5 10 15];
for i=1:4
2
Xw(i,:)=(sin(w*(N(i)+1/2)))./(sin(w/2));
end
MagX1=abs(Xw(1,:))/max(Xw(1,:));
MagX2=abs(Xw(2,:))/max(Xw(2,:));
MagX3=abs(Xw(3,:))/max(Xw(3,:));
MagX4=abs(Xw(4,:))/max(Xw(4,:));
subplot(221);
plot(w/pi,MagX1);
xlabel(’\omega/\pi’);
title(’N=2’);
subplot(222);
plot(w/pi,MagX2);
xlabel(’\omega/\pi’);
title(’N=5’);
subplot(223);
plot(w/pi,MagX3);
xlabel(’\omega/\pi’);
title(’N=10’);
subplot(224);
plot(w/pi,MagX4);
xlabel(’\omega/\pi’);
title(’N=15’);
As N increases the main lobe width decreases.
Example-2: Determine and plot the discrete-time Fourier transform (DTFT) of a sinusoidal signal
x(n) = cos(πn/4) , 0 ≤ n ≤ 100
Investigate its periodicity.
Solution: clc; clear all; close all;
n=0:100;
xn=cos(n*pi/4);
w=-3*pi:0.01*pi:3*pi;
Xw=xn*exp(-j*(n’*w));
MagX=abs(Xw);
plot(w/pi,abs(Xw));
xlabel(’\omega/\pi’);
ylabel(’Magnitude’);
We have plotted the DTFT over the range [−3π, 3π] to show the periodicity of the DTFT.
Comments
Post a Comment