Main Content

fourier

Fourier transform

Description

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

example

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

example

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

example

Examples

Fourier Transform of Common Inputs

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

FunctionInput and Output

Rectangular pulse

syms a b t
f = rectangularPulse(a,b,t);
f_FT = fourier(f)
f_FT =
- (sin(a*w) + cos(a*w)*1i)/w + (sin(b*w) + cos(b*w)*1i)/w

Unit impulse (Dirac delta)

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

Absolute value

f = a*abs(t);
f_FT = fourier(f)
f_FT =
-(2*a)/w^2

Step (Heaviside)

f = heaviside(t);
f_FT = fourier(f)
f_FT =
pi*dirac(w) - 1i/w

Constant

f = a;
f_FT = fourier(a)
f_FT =
pi*dirac(1, w)*2i
Cosine
f = a*cos(b*t);
f_FT = fourier(f)
f_FT =
pi*a*(dirac(b + w) + dirac(b - w))
Sine
f = a*sin(b*t);
f_FT = fourier(f)
f_FT =
pi*a*(dirac(b + w) - dirac(b - w))*1i
Sign
f = sign(t);
f_FT = fourier(f)
f_FT =
-2i/w

Triangle

syms c
f = triangularPulse(a,b,c,t);
f_FT = fourier(f)
f_FT =
-(a*exp(-b*w*1i) - b*exp(-a*w*1i) - a*exp(-c*w*1i) + ...
c*exp(-a*w*1i) + b*exp(-c*w*1i) - c*exp(-b*w*1i))/ ...
(w^2*(a - b)*(b - c))

Right-sided exponential

Also calculate transform with condition a > 0. Clear assumptions.

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

assume(a > 0)
f_FT_condition = fourier(f)
assume(a,'clear')
f_FT =
1/(abs(a) + w*1i) - (sign(abs(a))/2 - 1/2)*fourier(exp(-t*abs(a)),t,w)

f_FT_condition =
1/(a + w*1i)

Double-sided exponential

Assume a > 0. Clear assumptions.

assume(a > 0)
f = exp(-a*t^2);
f_FT = fourier(f)
assume(a,'clear')
f_FT =
(pi^(1/2)*exp(-w^2/(4*a)))/a^(1/2)

Gaussian

Assume b and c are real. Simplify result and clear assumptions.

assume([b c],'real')
f = a*exp(-(t-b)^2/(2*c^2));
f_FT = fourier(f)

f_FT_simplify = simplify(f_FT)
assume([b c],'clear')
f_FT =
(a*pi^(1/2)*exp(- (c^2*(w + (b*1i)/c^2)^2)/2 - b^2/(2*c^2)))/ ...
    (1/(2*c^2))^(1/2)

f_FT_simplify =
2^(1/2)*a*pi^(1/2)*exp(-(w*(w*c^2 + b*2i))/2)*abs(c)

Bessel of first kind with nu = 1

Simplify the result.

syms x
f = besselj(1,x);
f_FT = fourier(f);
f_FT = simplify(f_FT)
f_FT =
(2*w*(heaviside(w - 1)*1i - heaviside(w + 1)*1i))/(1 - w^2)^(1/2)

Specify Independent Variable and Transformation Variable

Compute 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);
fourier(f)
ans =
pi^(1/2)*exp(- t^2 - w^2/4)

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
fourier(f,y)
ans =
pi^(1/2)*exp(- t^2 - y^2/4)

Specify both the independent and transformation variables as t and y in the second and third arguments, respectively.

fourier(f,t,y)
ans =
pi^(1/2)*exp(- x^2 - y^2/4)

Fourier Transforms Involving Dirac and Heaviside Functions

Compute the following Fourier transforms. The results are in terms of the Dirac and Heaviside functions.

syms t w
fourier(t^3, t, w)
ans =
-pi*dirac(3, w)*2i
syms t0
fourier(heaviside(t - t0),t,w)
ans =
exp(-t0*w*1i)*(pi*dirac(w) - 1i/w)

Specify Fourier Transform Parameters

Specify parameters of the Fourier transform.

Compute the Fourier transform of f using the default values of the Fourier parameters c = 1, s = -1. For details, see Fourier Transform.

syms t w
f = t*exp(-t^2);
fourier(f,t,w)
ans =
-(w*pi^(1/2)*exp(-w^2/4)*1i)/2

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

sympref('FourierParameters',[1 1]);
fourier(f,t,w)
ans =
(w*pi^(1/2)*exp(-w^2/4)*1i)/2

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

sympref('FourierParameters', [1/(2*sym(pi)), 1]);
fourier(f,t,w)
ans =
(w*exp(-w^2/4)*1i)/(4*pi^(1/2))

Preferences set by 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');

Fourier Transform of Array Inputs

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

syms a b c d w x y z
M = [exp(x) 1; sin(y) i*z];
vars = [w x; y z];
transVars = [a b; c d];
fourier(M,vars,transVars)
ans =
[                 2*pi*exp(x)*dirac(a),     2*pi*dirac(b)]
[ -pi*(dirac(c - 1) - dirac(c + 1))*1i, -2*pi*dirac(1, d)]

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

fourier(x,vars,transVars)
ans =
[ 2*pi*x*dirac(a), pi*dirac(1, b)*2i]
[ 2*pi*x*dirac(c),   2*pi*x*dirac(d)]

If Fourier Transform Cannot Be Found

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

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

Return the original expression by using ifourier.

ifourier(F,w,t)
ans =
f(t)

Input Arguments

collapse all

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

Independent variable, specified as a symbolic variable. This variable is often called the "time variable" or the "space variable." If you do not specify the variable, then fourier uses the function symvar to determine the independent variable.

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

More About

collapse all

Fourier Transform

The Fourier transform of the expression f = f(x) with respect to the variable x at the point w is

F(w)=cf(x)eiswxdx.

c and s are parameters of the Fourier transform. The fourier function uses c = 1, s = –1.

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 F., "Tables of Fourier Transforms and Fourier Transforms of Distributions." Springer, 1990.

Version History

Introduced before R2006a