You are on page 1of 9

Frequency samples of DTFT

I compute the frequency samples of DTFT. Three parameters are the number of points, the numerator and the denominator. Then i draw four figures. They are real part of DTFT, imaginary part of DTFT, magnitude spectrum of DTFT and phase spectrum of DTFT respectively.
w=0:pi/256:pi; %the number of discrete-time points

num=[0.7 -0.5 0.3 1]; %the numerator den=[1 0.3 -0.5 0.7]; %the denominator h=freqz(num,den,w); subplot(2,2,1) plot(w/pi,real(h)); % real part of DTFT title('real part of DTFT') subplot(2,2,2) plot(w/pi,imag(h)); % imaginary part of DTFT title('imaginary part of DTFT') subplot(2,2,3) plot(w/pi,abs(h)); % magnitude spectrum of DTFT title('magnitude spectrum of DTFT') subplot(2,2,4) plot(w/pi,angle(h)); % phase spectrum of DTFT title('phase spectrum of DTFT')

Time Shifting Property of DTFT


I draw four figures. They are the magnitude spectrum of original sequence and time-shifted sequence and the phase Spectrum of original sequence and time-shifted sequence respectively
w=-pi:2*pi/255:pi; %the number of discrete-time points is 256 num=[0.7 -0.5 0.3 1]; %the numerator den=[1 0.3 -0.5 0.7]; %the denominator D=10; h1=freqz(num,1,w); h2=freqz([zeros(1,D) num],1,w); %numerator delay for D points subplot(2,2,1) plot(w/pi,abs(h1)); % the magnitude spectrum of original sequence

title('the magnitude spectrum of original sequence') subplot(2,2,2) plot(w/pi,angle(h1)); % the phase Spectrum of original sequence title('the phase Spectrum of original sequence') subplot(2,2,3) plot(w/pi,abs(h2)); % the magnitude spectrum of time-shifted sequence title('the magnitude spectrum of time-shifted sequence') subplot(2,2,4) plot(w/pi,angle(h2)); % the phase spectrum of time-shifted sequence title('the phase spectrum of time-shifted sequence'

Frequency shifting property of DTFT


Then again i draw four figures. They are the magnitude spectrum of original sequence and frequency-shifted sequence and the phase Spectrum of original sequence and frequency-shifted sequence respectively.
w=-pi:2*pi/255:pi; w0=0.4*pi; num=[0.7 -0.5 0.3 1]; %the numerator den=[1 0.3 -0.5 0.7]; %the denominator L=length(num); h1=freqz(num,1,w); % original sequence n=0:L-1; num2=exp(w0*i*n).*num; %frequency-shifting of w0 h2=freqz(num2,1,w); % frequency-shifted sequence subplot(2,2,1) plot(w/pi,abs(h1)); % the magnitude spectrum of original sequence title('the magnitude spectrum of original sequence') subplot(2,2,2) plot(w/pi,angle(h1)); % the phase Spectrum of original sequence title('the phase Spectrum of original sequence') subplot(2,2,3) plot(w/pi,abs(h2)); % the magnitude spectrum of frequency-shifted sequence title('the magnitude spectrum of frequency-shifted sequence') subplot(2,2,4) plot(w/pi,angle(h2)); % the phase spectrum of frequency-shifted sequence

title('the phase spectrum of frequency-shifted sequence')

The convolution of the DTFT


Then i draw four figures. They are the magnitude spectrum of hp and h3 and the phase Spectrum of hp and h3 respectively.
num1=[0.7 -0.5 0.3 1]; %num1 num2=[1.2 0.4 -0.5 0.8]; %num2 w=-pi:2*pi/255:pi; y=conv(num1,num2); h1=freqz(num1,1,w); h2=freqz(num2,1,w); hp=h1.*h2; %pay attentions of dot h3=freqz(y,1,w);

subplot(2,2,1) plot(w/pi,abs(hp)); % the magnitude spectrum of hp title('the magnitude spectrum of hp') subplot(2,2,2) plot(w/pi,angle(hp)); % the phase Spectrum of hp title('the phase Spectrum of hp') subplot(2,2,3) plot(w/pi,abs(h3)); % the magnitude spectrum of h3 title('the magnitude spectrum of h3') subplot(2,2,4) plot(w/pi,angle(h3)); % the phase Spectrum of h3 title('the phase Spectrum of h3')

The modulation property of DTFT


Then i draw three figures. They are the magnitude spectrum of first sequence, second sequence and product sequence respectively.
num1=[0.7 -0.5 0.3 1]; %num1 num2=[1.2 0.4 -0.5 0.8]; %num2 w=-pi:2*pi/255:pi; y=num1.*num2; %pay attentions of dot h1=freqz(num1,1,w); h2=freqz(num2,1,w); h3=freqz(y,1,w); subplot(3,1,1) plot(w/pi,abs(h1)); % the magnitude spectrum of first sequence title('the magnitude spectrum of first sequence') subplot(3,1,2) plot(w/pi,abs(h2)); % the magnitude spectrum of second sequence title('the magnitude spectrum of second sequence') subplot(3,1,3) plot(w/pi,abs(h3)); % the magnitude spectrum of product sequence title('the magnitude spectrum of product sequence')

The time-reversal property of DTFT


Then i draw four figures. They are the magnitude spectrum of original sequence and time-reversed sequence and the phase Spectrum of original sequence and time-reversed sequence respectively.
num=[0.7 -0.5 0.3 1]; %the numerator w=-pi:2*pi/255:pi; L=length(num)-1; h1=freqz(num,1,w); h2=freqz(fliplr(num),1,w); h3=exp(w*L*1i).*h2; %pay attention of dot subplot(2,2,1) plot(w/pi,abs(h1)); % the magnitude spectrum of original sequence title('the magnitude spectrum of original sequence')

subplot(2,2,2) plot(w/pi,angle(h1)); % the phase Spectrum of original sequence title('the phase Spectrum of original sequence') subplot(2,2,3) plot(w/pi,abs(h3)); % the magnitude spectrum of time-reversed sequence title('the magnitude spectrum of time-reversed sequence') subplot(2,2,4) plot(w/pi,angle(h3)); % the phase spectrum of time-reversed sequence title(' the phase spectrum of time-reversed sequence')

You might also like