Main Content

fourier

Fourier transform of symbolic expression or function

Description

FT = fourier(f) returns the Fourier transform of f. By default, the function symvar determines the independent variable, and w is the transformation variable.

example

FT = fourier(f,transVar) uses the transformation variable transVar instead of w.

example

FT = fourier(f,var,transVar) uses the independent variable var and the transformation variable transVar instead of symvar(f,1) and w, respectively.

example

Examples

collapse all

Compute the Fourier transform of common functions. By default, the transform is in terms of w.

Find the Fourier transform of a rectangular pulse function.

syms a b t
f = rectangularPulse(a,b,t);
FT = fourier(f)
FT = 

-sin(aw)+cos(aw)iw+sin(bw)+cos(bw)iw

Find the Fourier transform of a unit impulse (Dirac delta function).

f = dirac(t);
FT = fourier(f)
FT = 1

Find the Fourier transform of the absolute value function.

f = a*abs(t);
FT = fourier(f)
FT = 

-2aw2

Find the Fourier transform of the step function (Heaviside function).

f = heaviside(t);
FT = fourier(f)
FT = 

πδdirac(w)-iw

Find the Fourier transform of a constant.

f = a;
FT = fourier(f)
FT = 2πδdirac(w)i

Find the Fourier transform of the cosine function.

f = a*cos(b*t);
FT = fourier(f)
FT = πaδdirac(b+w)+δdirac(b-w)

Find the Fourier transform of the sine function.

f = a*sin(b*t);
FT = fourier(f)
FT = πaδdirac(b+w)-δdirac(b-w)i

Find the Fourier transform of the sign function.

f = sign(t);
FT = fourier(f)
FT = 

-2iw

Find the Fourier transform of the right-sided exponential function without any assumptions.

f = exp(-t*abs(a))*heaviside(t);
FT = fourier(f)
FT = 

1|a|+wi-sign(|a|)2-12fourier(e-t|a|,t,w)

Find the Fourier transform of the right-sided exponential function, assuming that a > 0. Clear the assumption after computing the Fourier transform.

assume(a > 0)
FTwithAssumption = fourier(f)
FTwithAssumption = 

1a+wi

assume(a,"clear")

Find the Fourier transform of the double-sided exponential function, assuming that a > 0. Clear the assumption after computing the Fourier transform.

assume(a > 0)
f = exp(-a*t^2);
FTwithAssumption = fourier(f)
FTwithAssumption = 

πe-w24aa

assume(a,"clear")

Find the Fourier transform of a Gaussian function, assuming that b and c are real. Simplify the result and clear the assumptions after computing the Fourier transform.

syms c
assume([b c],"real")
f = a*exp(-(t-b)^2/(2*c^2));
FT = fourier(f);
FTsimplified = simplify(FT)
FTsimplified = 

2aπe-wwc2+2bi2|c|

assume([b c],"clear")

Find the Fourier transform of the Bessel function of the first kind with nu = 1. Simplify the result.

syms x
f = besselj(1,x);
FT = fourier(f);
FTsimplified = simplify(FT)
FTsimplified = 

-2wrectangularPulse(-1,1,-w)i1-w2

Find the Fourier transform of exp(-t^2-x^2). By default, symvar determines the independent variable, and w is the transformation variable. Here, symvar chooses x.

syms t x
f = exp(-t^2-x^2);
FT = fourier(f)
FT = 

πe-t2-w24

Specify the transformation variable as y. If you specify only one variable, that variable is the transformation variable. symvar still determines the independent variable.

syms y
FT = fourier(f,y)
FT = 

πe-t2-y24

Specify the independent and transformation variables as t and y, respectively.

FT = fourier(f,t,y)
FT = 

πe-x2-y24

Create a rectangular pulse with a starting point at –1/2 and an endpoint at 1/2.

syms t
f1 = rectangularPulse(-1/2,1/2,t);

Find its Fourier transform. Simplify the result. Here, the Fourier transform contains only the real part.

FT1 = fourier(f1);
FT1 = simplify(FT1)
FT1 = 

2sin(w2)w

Plot the rectangular pulse in a 2-by-2 tiled chart layout by using fplot. Plot the real and imaginary parts of its Fourier transform.

tiledlayout(2,2)

nexttile
fplot(f1)
xlabel("$t$",Interpreter="latex")
ylabel("$f(t)$",Interpreter="latex")
title("Rectangular Pulse")

nexttile
fplot(real(FT1),[-50 50])
hold on
fplot(imag(FT1),[-50 50])
xlabel("$w$",Interpreter="latex")
ylabel("FT($w$)",Interpreter="latex")
title("Fourier Transform")
legend("Re(FT)","Im(FT)",Location="northeastoutside")

Figure contains 2 axes objects. Axes object 1 with title Rectangular Pulse, xlabel $t$, ylabel $f(t)$ contains an object of type functionline. Axes object 2 with title Fourier Transform, xlabel $w$, ylabel FT($w$) contains 2 objects of type functionline. These objects represent Re(FT), Im(FT).

Next, create another rectangular pulse with a starting point at 0 and an endpoint at 1.

f2 = rectangularPulse(0,1,t);

Find its Fourier transform. Here, the Fourier transform contains both real and imaginary parts.

FT2 = fourier(f2)
FT2 = 

sin(w)+cos(w)iw-iw

Plot the rectangular pulse. Plot the real and imaginary parts of its Fourier transform.

nexttile
fplot(f2)
xlabel("$t$",Interpreter="latex")
ylabel("$f(t)$",Interpreter="latex")

nexttile
fplot(real(FT2),[-50 50])
hold on
fplot(imag(FT2),[-50 50])
xlabel("$w$",Interpreter="latex")
ylabel("FT($w$)",Interpreter="latex")
legend("Re(FT)","Im(FT)",Location="northeastoutside")

Figure contains 4 axes objects. Axes object 1 with title Rectangular Pulse, xlabel $t$, ylabel $f(t)$ contains an object of type functionline. Axes object 2 with title Fourier Transform, xlabel $w$, ylabel FT($w$) contains 2 objects of type functionline. These objects represent Re(FT), Im(FT). Axes object 3 with xlabel $t$, ylabel $f(t)$ contains an object of type functionline. Axes object 4 with xlabel $w$, ylabel FT($w$) contains 2 objects of type functionline. These objects represent Re(FT), Im(FT).

Find the Fourier transform of t^3. The result is in terms of the third derivative of the Dirac delta function.

syms t w
FT = fourier(t^3,t,w)
FT = -2πδdirac(w)i

Find the Fourier transform of the Heaviside function with a discontinuity at t0.

syms t0
FT = fourier(heaviside(t - t0),t,w)
FT = 

e-t0wiπδdirac(w)-iw

As described in the More About section, c and s are parameters of the Fourier transform. By default, the fourier function uses c=1 and s=-1. However, you can change those parameter values by using sympref.

Compute the Fourier transform of t*exp(-t^2) using the default values of the Fourier parameters.

syms t w
f = t*exp(-t^2);
FT = fourier(f,t,w)
FT = 

-wπe-w24i2

Change the Fourier parameters to c = 1 and s = 1 by using sympref, and compute the transform again. The result changes.

sympref("FourierParameters",[1 1]);
FT = fourier(f,t,w)
FT = 

wπe-w24i2

Change the Fourier parameters to c = 1/(2*pi) and s = 1, and compute the transform again. The result changes.

sympref("FourierParameters",[1/(2*sym(pi)) 1]);
FT = fourier(f,t,w)
FT = 

we-w24i4π

Symbolic settings that you set using sympref persist through your current and future MATLAB® sessions. Restore the default values of c and s by setting FourierParameters to "default".

sympref("FourierParameters","default");

Find the Fourier transform of the matrix M. Specify the independent and transformation variables for each matrix element by using matrices of the same size. When the arguments are nonscalar, fourier acts on them element-wise.

syms a b c d w x y z
M = [exp(x) 1; sin(y) 1i*z];
vars = [w x; y z];
transVars = [a b; c d];
FT = fourier(M,vars,transVars)
FT = 

(2πexδdirac(a)2πδdirac(b)-πδdirac(c-1)-δdirac(c+1)i-2πδdirac(d))

If you call fourier with both scalar and nonscalar arguments, then it expands the scalar arguments to match the nonscalar arguments by using scalar expansion. Nonscalar arguments must be the same size.

FT = fourier(x,vars,transVars)
FT = 

(2πxδdirac(a)2πδdirac(b)i2πxδdirac(c)2πxδdirac(d))

If fourier cannot transform the input, then it returns an unevaluated call.

syms f(t) w
FT = fourier(f,t,w)
FT = fourier(f(t),t,w)

Return the original expression by using ifourier.

f = ifourier(FT,w,t)
f = f(t)

Find the 2-D Fourier transform by independently applying a sequence of 1-D Fourier transforms to each of the independent variables.

In this example, set the Fourier parameters to c=1 and s=2π such that the formula for the 2-D Fourier transform is

F(u,v)=--f(x,y)ei(2πux+2πvy)dxdy.

You can specify these parameters by using sympref.

sympref("FourierParameters",[1 2*sym(pi)]);

Find the 2-D Fourier transform of a 2-D unit rectangle located at the origin with width a and height b. Perform the 1-D Fourier transforms on the variable x, followed by the variable y. Simplify the result.

syms x y a b real
f(x,y) = rectangularPulse(-a/2,a/2,x)*rectangularPulse(-b/2,b/2,y);
syms u v
FT = fourier(f,x,u);
FT = fourier(FT,y,v);
FT = simplify(FT)
FT = 

sin(πau)sin(πbv)uvπ2

Find the Fourier transform of a 2-D Gaussian function with standard deviation σ in both the x- and y-directions.

syms sigma real
f(x,y) = 1/2/sym(pi)/sigma^2*exp((-x^2-y^2)/2/sigma^2);
syms u v
FT = fourier(f,x,u);
FT = fourier(FT,y,v);
FT = simplify(FT)
FT = e-2σ2π2u2+v2

Find the Fourier transform of two point sources located at (x,y)=(0,a) and (x,y)=(0,-a).

f(x,y) = 1/2*dirac(x)*(dirac(y-a)+dirac(y+a));
FT = fourier(f,x,u);
FT = fourier(FT,y,v);
FT = simplify(FT)
FT = cos(2πav)

Find the Fourier transform of a unit circle aperture. Define the unit circle by using the heaviside function.

f(x,y) = heaviside(x^2+y^2-1);
FT = fourier(f,x,u);
FT = fourier(FT,y,v)
FT = fourier(fourier(heaviside(x2+y2-1),x,u),y,v)

Here, the fourier function cannot transform the input function and returns an unevaluated call. As an alternative, you can find the 2-D Fourier transform numerically by using the fft2 function. For an example of how to find the 2-D Fourier transform of a circular aperture, see 2-D Fourier Transforms.

Symbolic settings that you set using sympref persist through your current and future MATLAB sessions. Restore the default settings.

sympref("default");

Input Arguments

collapse all

Input, specified as a symbolic expression, function, vector, or matrix.

Transformation variable, specified as a symbolic variable, expression, vector, or matrix. This variable is often referred to as the "frequency variable." By default, fourier uses w. If w is the independent variable of f, then fourier uses v.

Independent variable, specified as a symbolic variable, vector, or matrix. This variable is often referred to as the "time variable" or the "space variable." If you do not specify this argument, then fourier uses the function symvar(f,1) to determine the independent variable.

More About

collapse all

Tips

  • If any argument is an array, then fourier acts element-wise on all elements of the array.

  • If the first argument contains a symbolic function, then the second argument must be a scalar.

  • To compute the inverse Fourier transform, use ifourier.

  • fourier does not transform piecewise. Instead, try to rewrite piecewise by using the functions heaviside, rectangularPulse, or triangularPulse.

References

[1] Oberhettinger, Fritz. Tables of Fourier Transforms and Fourier Transforms of Distributions. Berlin, Heidelberg: Springer Berlin Heidelberg, 1990.

Version History

Introduced before R2006a