Mehran University of Engineering and Technology, SZAB Campus, Khairpur Mir’s
Department of Electrical Engineering
Signals & Systems
Lab #09
Name: Roll No:
Score: Signature: Date:
Fourier Transform
Objective
1. To verify the Amplitude and Phase spectra of aperiodic signals using MATLAB and Fourier
Transform.
2. To plot and observe the actual signals and their spectra
Theory
Fourier Transform
The Fourier transform is in fact an extension of the Fourier series, which doesn’t accurately
approximate continuous-time aperiodic signals. The Fourier transform of a continuous time signal
x(t) is represented by X(f). The Fourier transform is obtained by extending the expansion interval to
infinity, i.e. T→∞. The resulting mathematical form of the Fourier transform is:
The inverse Foruier transform on the other hand can be given as
In Matlab environment, the Fourier transform can be computed as by using the following
command:
fourier(f) returns the Fourier transform of ‘f’ using the default independent variable x and the
default transformation variable w. Similarly,
ifourier(F) returns the inverse Fourier transform of F using the default independent variable w for
the default transformation variable x.
-x
In order to find Fourier transform you need to use a variable symbol such as in e , x is the symbolic
variable. In Matlab, we need to define ‘x’ as symbol which could be done by using the Matlab
command “syms()” .
Go to Mathworks page and read about “syms()” and why we are using it here.
Page 1 of 6
Solve the following Fourier Transform examples in Matlab. Get help from Google and try to
understand how we are calculating the Fourier transform of each function.
Task -1 Fourier Transform Examples in Matlab
Fourier Transform MATLAB Commands
syms x;
f = exp(-x^2);
fourier(f)
answer will be pi^(1/2)/exp(w^2/4)
syms x y;
f = exp(-x^2);
fourier(f,x,y)
syms w;
g = exp(-abs(w));
a = fourier(g)
returns
a=
2/(v^2 + 1)
pretty(a)
2
------
2
v+1
syms x u;
f = x*exp(-abs(x));
a = fourier(f,u)
returns
Page 2 of 6
a=
-(u*4*i)/(u^2 + 1)^2
Comments: Please perform all the above examples in Matlab for your understanding.
Lab Task(s)
-3t
1) A function x(t)=e u(t) is given. Find the Fourier transform of this function in your
notebooks and draw its frequency domain amplitude spectrum X(w) and its magnitude
spectrum |X(w)|.
Hint: First of all plot the function x(t), and then X(w) and its magnitude spectrum |X(w) using
the subplot() command. For frequency domain plotting, use the frequency from -1 to 1 Hz.
-3t
2) Plot the phase spectrum of the signal x(t)=e u(t), after finding its Fourier transform.
Please explore how you can plot the phase spectrum in Matlab. Use the frequency from -1
to 1 Hz.
Program:
t=-1:0.01:3;
ut=[zeros(1,100) ones(1,301)];
a=3;
xt=exp(-a*t).*ut;
f=-1:0.001:1;
Xf=1./(a+j*2*f*pi)
xphase=angle(Xf);
xamp=abs(Xf);
subplot(2,2,1)
plot(t, xt)
grid
subplot(2,2,2)
plot(f, xphase)
grid
subplot(2,2,3)
plot(f, xamp)
grid
Fourier Transform Matlab Function:
Page 3 of 6
In Matlab, we can compute the Fourier transform of a signal using the function fft()
fft(X) computes the discrete Fourier transform (DFT) of X using a fast Fourier transform (FFT)
algorithm.
Y = fft(X,n) returns the n-point DFT. If no value is specified, Y is the same size as X.
Page 4 of 6
Example:
Program1:
When analyzing the frequency components of signals, it can be helpful to shift the zero-frequency
components to the center. Create a signal S, compute its Fourier transform, and plot the power.
S = cos(2*pi*15*t)
fs = 100; % sampling
frequency t = 0:(1/fs):(10-1/fs); % time
vector
S =
cos(2*pi*15*t); n
= length(S);
X = fft(S);
f = (0:n-1)*(fs/n); %frequency
range power = abs(X).^2/n; %power
plot(f,power)
%Shift the zero-frequency components and plot the zero-centered power.
Y = fftshift(X);
fshift = (-n/2:n/2-1)*(fs/n); % zero-centered frequency
range powershift = abs(Y).^2/n; % zero-centered
power plot(fshift,powershift)
Program2
Use Fourier transforms to find the frequency components of a given signal having a frequency of
50 Hz and a sampling frequency of 1000 Hz. Take the signal length to be 1000. Please run the
following code and generate the results.
S = 0.7*sin(2*pi*50*t)
clear all; clc
Fs = 1000; % Sampling frequency
Ts = 1/Fs;
f = 50; % Sampling period
t = 0:Ts:1/f*10; % Plotting 10 cycles of a signal with step size Ts
S = 0.7*sin(2*pi*f*t); % Signal
L = length(S);
f1 = -Fs/2:Fs/L:Fs/2-1; % Defining the frequency axis for the signal from –Fs/2 to Fs/2. Here Fs/L
defines the frequency step size.
Y = fft(S); % Taking Fourier Transform
P2 = abs(Y/L); % Absolute to convert the complex values
P2 = fftshift(P2); % To shift the frequency spectrum
subplot(2,1,1)
plot(t,S)
title('Original Signal at 50 Hz')
xlabel('t (seconds)')
Page 5 of 6
ylabel('X(t)')
subplot(2,1,2)
plot(f1,P2)
title('Signal in Frequency Domain')
xlabel('f (Hz)')
ylabel('|P1(f)|')
Exercise
1. Write a MATLAB program, which generates and plots the:
a. Function x (t) =3(t/4),
b. Amplitude Density Spectrum,
c. Phase spectrum
2. A function consist of an addition of two signals is given below
S = 2*sin(2*pi*25*t) + 3*sin(2*pi*50*t);
Plot the time domain and frequency domain plot for the above signal using 10 cycles if the
sampling frequency is 1000 Hz.
Review Questions:
1. What is Fourier Transform?
2. What is Amplitude Density Spectrum?
3. What is Energy Density Spectrum?
Page 6 of 6
4. What is Phase Spectrum?
Final Check List:
Save your programs & turn off PC.
Submit your answers to questions, and results before the next laboratory.
Attach the prints of the plots you obtain in the exercises above with proper headings
including the function name and description.
Page 7 of 6