0% found this document useful (0 votes)
63 views6 pages

Fourier Transform in Matlab

Uploaded by

capanangfrency
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)
63 views6 pages

Fourier Transform in Matlab

Uploaded by

capanangfrency
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/ 6

Fourier Transform in MATLAB

Fourier Transform is a mathematical technique that helps to transform Time Domain function
x(t) to Frequency Domain function X(ω). In this article, we will see how to find Fourier
Transform in MATLAB.

The mathematical expression of the Fourier transform is:



X ( ω )=F { x (t ) }=∫ x (t) e
− jωt
dt
−∞

Using the above function one can generate a Fourier Transform of any expression. In MATLAB,
the fourier command returns the Fourier transform of a given function. Input can be
provided to the fourier function using 3 different syntaxes.

1. fourier(x): In this method, x is the time domain function whereas the independent
variable is determined by symvar and the transformation variable is w by default.
2. fourier(x,transvar): Here, x is the time domain function whereas transvar is the
transformation variable instead of w.
3. fourier(x,indepvar,transvar): In this syntax, x is the time domain function whereas
indepvar is the independent variable and transvar is the transformation variable instead
of symvar and w respectively.
2
For the following example, we find the Fourier transform of e−t

% MATLAB code to specify the variable t


% and u as symbolic ones The syms function
% creates a variable dynamically and
% automatically assigns to a MATLAB variable
% with the same name
syms t u

% define time domain function x(t)


x = exp(-t^2-u^2);

% fourier command to transform into


% frequency domain function X(w)

% using 1st syntax, where independent variable


% is determined by symvar (u in this case)
% and transformation variable is w by default.
X = fourier(x);

% using 2nd syntax, where transformation


% variable = y
X1=fourier(x,y);

% using 3rd syntax, where independent


% variable = t & transformation variable = y
X2=fourier(x,t,y);
% Display the output value
disp('1. Fourier Transform of exp(-t^2-u^2) using fourier(x) :')
disp(X);

disp('2. Fourier Transform of exp(-t^2-u^2) using fourier(x,y) :')


disp(X1);

disp('3. Fourier Transform of exp(-t^2-u^2) using fourier(x,t,y) :')


disp(X2);

Place a screenshot of your output here:

Another example, find the Fourier transform of a*|t|.

% MATLAB code for specify the variable


% a and t as symbolic ones
syms a t

% define time domain function x(t)


% where t=independent variable & a=constant
x = a*abs(t);

% fourier command to transform into frequency


% domain function X(w)
% using 1st syntax
X = fourier(x);

% using 2nd syntax, where transformation


% variable = y
X1 = fourier(x,y);

% using 3rd syntax, where transformation variable


% = y & independent
% variable = t (as t is the only other variable)
X2 = fourier(x,t,y);

% Display the output value


disp('1. Fourier Transform of a*abs(t) using fourier(x):')
disp(X);

disp('2. Fourier Transform of a*abs(t) using fourier(x,y):')


disp(X1);
disp('3. Fourier Transform of a*abs(t) using fourier(x,t,y):')
disp(X2);

Place a screenshot of your output here:

Generate codes for MATLAB that will solve two function in time-domain of your choice, just
like previous codes. These functions should be different from the examples. Then obtain a
screenshot of your output.

MATLAB Code for function 1:

Screenshot:

MATLAB Code for function 2:

Screenshot:
Inverse Fourier Transform in MATLAB
Inverse Fourier Transform helps to return from Frequency domain function X(ω) to Time
Domain x(t). In this article, we will see how to find Inverse Fourier Transform in MATLAB.

The mathematical expression for Inverse Fourier transform is:



1
−1
x (t)=F { X (ω) }= ∫
2 π −∞
jωt
X (ω)e dω

In MATLAB, ifourier command returns the Inverse Fourier transform of given function.
Input can be provided to ifourier function using 3 different syntax.

 ifourier(X): In this method, X is the frequency domain function whereas by default


independent variable is w (If X does not contain w, then ifourier uses the function
symvar) and the transformation variable is x.
 ifourier(X,transvar): Here, X is the frequency domain function whereas transvar is the
transformation variable instead of x.
 ifourier(X,indepvar,transvar): In this syntax, X is the frequency domain function
whereas indepvar is the independent variable and transvar is the transformation
variable instead of w and x respectively.
2
−ω
For the following example, we find for the Inverse Fourier Transform of 4
e
% MATLAB code specify the variable
% w and t as symbolic ones
syms w t

% define Frequency domain function X(w)


X=exp(-w^2/4);

% ifourier command to transform into


% time domain function x(t)
% using 1st syntax, where by default
% independent variable = w
% and transformation variable is x .
x1 = ifourier(X);

% using 2nd syntax, where transformation variable = t


x2 = ifourier(X,t);

% using 3rd syntax, where independent variable


% = w (as there is no other
% variable in function) and transformation
% variable = t
x3 = ifourier(X,w,t);

% Display the output value


disp('1. Inverse Fourier Transform of exp(-w^2/4) using
ifourier(X) :')
disp(x1);

disp('2. Inverse Fourier Transform of exp(-w^2/4) using


ifourier(X,t) :')
disp(x2);

disp('3. Inverse Fourier Transform of exp(-w^2/4) using


ifourier(X,w,t) :')
disp(x3);

Place a screenshot of your output here:

2 2
Another example, find the Inverse Fourier transform of e−ω −a .

% MATLAB code to specify the variable %


% a w and t as symbolic ones %
syms a w t

% define Frequency domain function X(w)


X=exp(-w^2-a^2);

% ifourier command to transform into


% time domain function x(t)
% using 1st syntax, where by default
% independent variable = w
% and transformation variable is x .
x1=ifourier(X);

% using 2nd syntax, where transformation


% variable = t
x2=ifourier(X,t);

% using 3rd syntax, where independent


% variable = w (as there is no other
% variable in function) and transformation
% variable = t
x3=ifourier(X,w,t);

% Display the output value


disp('1. Inverse Fourier Transform of exp(-w^2-a^2) using
ifourier(X) :')
disp(x1);

disp('2. Inverse Fourier Transform of exp(-w^2-a^2) using


ifourier(X,t) :')
disp(x2);

disp('3. Inverse Fourier Transform of exp(-w^2-a^2) using


ifourier(X,w,t) :')
disp(x3);

Place a screenshot of your output here:

Generate codes for MATLAB that will solve two functions in frequency-domain of your choice,
just like previous codes. These functions should be different from the examples. Then obtain a
screenshot of your output.

MATLAB Code for function 1:

Screenshot:

MATLAB Code for function 2:

Screenshot:

You might also like