0% found this document useful (0 votes)
124 views

Batangas State University College of Engineering, Architecture & Fine Arts

This document contains a laboratory activity on the discrete-time Fourier transform (DTFT). It includes the development of functions to display the DTFT, compute the DTFT, and determine properties of the DTFT such as linearity, time shifting, frequency shifting, conjugation, folding, and symmetry. It also uses the DTFT function to transform 5 sequences and plot the magnitude and phase responses.

Uploaded by

Abby gxle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
124 views

Batangas State University College of Engineering, Architecture & Fine Arts

This document contains a laboratory activity on the discrete-time Fourier transform (DTFT). It includes the development of functions to display the DTFT, compute the DTFT, and determine properties of the DTFT such as linearity, time shifting, frequency shifting, conjugation, folding, and symmetry. It also uses the DTFT function to transform 5 sequences and plot the magnitude and phase responses.

Uploaded by

Abby gxle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Republic of the Philippines

BATANGAS STATE UNIVERSITY


Pablo Borbon Main II, Batangas City
College of Engineering, Architecture & Fine Arts
www.batstate-u.edu.ph Tel. No. (043) 425-0139 loc. 118

ELECTRONICS, INSTRUMENTATION AND CONTROL, AND MECHATRONICS


ENGINEERING DEPARTMENT

ECE 415
SIGNALS, SPECTRA, AND SIGNAL PROCESSING

LABORATORY ACTIVITY NO. 3


THE DISCRETE-TIME FOURIER TRANSFORM

MALIGLIG, ABBYGALE D.
ECE - 4201

ENGR. RALPH GERARD B. SANGALANG


Instructor

APRIL 18, 2018


Laboratory Exercise 3

Develop an algorithm to display the different components of a transformed function and name the
function disp_dtft. The function should have an input that determines how many equally
spaced points are displayed. The function should also display the sequence.

function [X]= disp_dtft(x,n,w,k)


X=x*exp(-j*n'*w);
magX=abs(X); angX=angle(X);
realX=rea;(X); imagX=imag(X);
subplot(2,2,1); stem(k/500,magX); xlabel('Frequency in /pi Units');
title('Magnitude Part');
subplot(2,2,3); stem(k/500,angX/pi); xlabel('Frequency in /pi Units');
title('Angle Part');
subplot(2,2,2); stem(k/500,realX); xlabel('Frequency in /pi Units');
title('Real Part');
subplot(2,2,4); stem(k/500,imagX); xlabel('Frequency in /pi Units');
title('Imaginary Part');

Write a MATLAB function to compute the DTFT of finite-duration sequence. The format of the
function should be

Function [X] = dtft(x,n,w)


% Computes Discrete-time fourier transform
% [X] = dtft(x,n,w)
% X = DTFT values computed at w frequencies
% x = finite duration sequence over n
% n = sample position vector
% w = frequency location vector

function [X] = dtft(x,n,w)


% Computes Discrete-time Fourier Transform
% [X] = dtft(x,n,w)
% X = DTFT values computed at w frequencies
% x = finite duration sequence over n (row vector)
% n = sample position row vector
% w = frequency row vector
X = x*exp(-j*n’*w);
end
Develop several functions that determines the different properties of the DTFT, i.e. Linearity,
Time Shifting, Frequency Shifting, Conjugation, Folding and Symmetry.

Linearity
function[L] = linearity(x1,x2,n,k)
alpha = 2; beta = 3;
L = alpha*x1 + beta*x2;
X1=dtft (x1,n,k);
X2 = dtft (x2,n,k);
X3 = dtft (L,n,k);
L1 = alpha*X1 + beta*X2;
error = max(abs(X3-L1))

Time Shifting
function [S] = shift (x,n,w,m1)
X = x*exp(-j*n'*w);
y = x;
m = n-m1;
Y = x*exp(-j*m'*w);
Y_check = (exp(-j*2).^w).*X;
error = max(abs(Y-Y_check))

Frequency Shifting
function [F] = frequency(x,n,w,yn)
% yn is the frequency phase shift
X = x*exp(-j*n'*w);
Y = yn.*x;
Y1 = Y*exp(-j*n'*w);

Conjugation
function [C] = conjugate (x,n,w)
X = dtft(x,n,w);
y = conj(x);
Y = dtft(y,n,w);
Y_check = conj(fliplr(X));
error = max(abs(Y-Y_check))

Folding
function [F] = folding (x,n,w)
X = dtft (x,n,w);
y = fliplr(x);
m = (-1).*(fliplr(n));
Y = dtft (y,m,w);
% verification
Y_check = fliplr(X);
error = max(abs(Y-Y_check))
Symmetry
function [Y] = symetry (x,n,w)
X = dtft(x,n,w);
[xe,xo,m] = evenodd(x,n);
XE = dtft (xe,m,w);
XO = dtft (xo,m,w);
XR = real(X); % verification
error1 = max(abs(XE-XR))
XI = imag(X);
error2 = max(abs(XO-j*XI))

Use the function dtft to show the transforms of the following sequences. Plot over the interval
−𝜋 ≤ 𝜔 ≤ 𝜋. Use 1001 equally spaced points.

1. 𝑥[𝑛] = (0.6)|𝑛| (𝑢[𝑛 + 10]) − 𝑢[𝑛 − 11])

%1
[x11,n11] = stepseq(-10,-11,11);
[x12,n12] = stepseq(11,-11,11);
[x13,n13] = sigadd(x11,n11,-x12,n12);
n1 = n13;
x1 = (0.6 .^ abs(n1)).*x13;
w1 = linspace(-pi,pi,201);
X1 = dtft(x1,n1,w1);
mag1 = abs(X1);
pha1 = angle(X1);
subplot(2,1,1); %Magnitude response
plot(w1/pi,mag1);
axis([-1 1 0 4.5]);
xlabel('\omega/\pi');
ylabel('|X|');
title('Magnitude response');
subplot(2,1,2); %Phase Response
plot(w1/pi,pha1*180/pi);
axis([-1,1,-180,180]);
xlabel('\omega/\pi');
ylabel('Degrees');
title('Phase Response');
2. 𝑥[𝑛] = 𝑛(0.9)𝑛 (𝑢[𝑛]) − 𝑢[𝑛 − 2])

%2
[x21,n21] = stepseq(0,0,22);
[x22,n22] = stepseq(21,0,22);
[x23,n23] = sigadd(x21,n21,-x22,n22);
n2 = n23; x2 = n2.*(0.9 .^ n2).*x23;
w2 = linspace(-pi,pi,201);
X2 = dtft(x2,n2,w2);
mag2 = abs(X2);
pha2 = angle(X2);
subplot(2,1,1); %Magnitude response
plot(w2/pi,mag2);
xlabel('\omega/\pi');
ylabel('|X|');
title('Magnitude response');
subplot(2,1,2); %Phase Response
plot(w2/pi,pha2*180/pi);
axis([-1,1,-200,200]);
xlabel('\omega/\pi’');
ylabel('Degrees');
title('Phase Response')
3. 𝑥[𝑛] = [𝑐𝑜𝑠0.5𝜋 + 𝑗𝑠𝑖𝑛0.5𝜋𝑛](𝑢[𝑛] − 𝑢[𝑛 − 51])

%3
[x31,n31] = stepseq(0,0,52);
[x32,n32] = stepseq(51,0,52);
[x33,n33] = sigadd(x31,n31,-x32,n32);
n3 = n33;
x3 = (cos(0.5*pi*n3)+1i*sin(0.5*pi*n3)).*x33;
w3 = linspace(-pi,pi,201);
X3 = dtft(x3,n3,w3);
mag3 = abs(X3);
pha3 = angle(X3);
subplot(2,1,1); %Magnitude response
plot(w3/pi,mag3);
xlabel('\omega/\pi');
ylabel('|X|');
title('Magnitude response');
subplot(2,1,2); %Phase Response
plot(w3/pi,pha3*180/pi);
axis([-1,1,-200,200]);
xlabel('\omega/\pi');
ylabel('Degrees');
title('Phase Response')
4. 𝑥[𝑛] = {4,3,2,1,1,2,3,4}

%4
x4 = [4 3 2 1 1 2 3 4];
n4 = [0:7];
w4 = linspace(-pi,pi,201);
X4 = dtft(x4,n4,w4);
mag4 = abs(X4);
pha4 = angle(X4);
subplot(2,1,1); %Magnitude response
plot(w4/pi,mag4);
axis([-1,1,0,25]);
xlabel('\omega/\pi');
ylabel('|X|');
title('Magnitude response');
subplot(2,1,2); %Phase Response
plot(w4/pi,pha4*180/pi);
axis([-1,1,-200,200]);
xlabel('\omega/\pi');
ylabel('Degrees');
title('Phase Response');
5. 𝑥[𝑛] = {4,3,2,1, −1, −2, −3, −4}

%5
x5 = [4 3 2 1 -1 -2 -3 -4];
n5 = [0:7];
w5 = linspace(-pi,pi,201);
X5 = dtft(x5,n5,w5);
mag5 = abs(X5);
pha5 = angle(X5);
subplot(2,1,1); %Magnitude response
plot(w5/pi,mag5);
axis([-1 1 0 20]);
xlabel('\omega/\pi');
ylabel('|X|');
title('Magnitude response');
subplot(2,1,2); %Phase Response
plot(w5/pi,pha5*180/pi);
axis([-1,1,-200,200]);
xlabel('\omega/\pi');
ylabel('Degrees');
title('Phase Response')

You might also like