2-D fast Fourier transform - MATLAB fft2 (2024)

2-D fast Fourier transform

collapse all in page

Syntax

Y = fft2(X)

Y = fft2(X,m,n)

Description

example

Y = fft2(X) returns the two-dimensional Fourier transform of a matrix X using a fast Fourier transform algorithm, which is equivalent to computing fft(fft(X).').'.

When X is a multidimensional array, fft2 computes the 2-D Fourier transform on the first two dimensions of each subarray of X that can be treated as a 2-D matrix for dimensions higher than 2. For example, if X is an m-by-n-by-1-by-2 array, then Y(:,:,1,1) = fft2(X(:,:,1,1)) and Y(:,:,1,2) = fft2(X(:,:,1,2)). The output Y is the same size as X.

example

Y = fft2(X,m,n) truncates X or pads X with trailing zeros to form an m-by-n matrix before computing the transform. If X is a matrix, then Y is an m-by-n matrix. If X is a multidimensional array, then fft2 shapes the first two dimensions of X according to m and n.

Examples

collapse all

Open Live Script

The 2-D Fourier transform is useful for processing 2-D signals and other 2-D data such as images.

Create and plot 2-D data with repeated blocks.

P = peaks(20);X = repmat(P,[5 10]);imagesc(X)

2-D fast Fourier transform - MATLAB fft2 (1)

Compute the 2-D Fourier transform of the data. Shift the zero-frequency component to the center of the output, and plot the resulting 100-by-200 matrix, which is the same size as X.

Y = fft2(X);imagesc(abs(fftshift(Y)))

2-D fast Fourier transform - MATLAB fft2 (2)

Pad X with zeros to compute a 128-by-256 transform.

Y = fft2(X,2^nextpow2(100),2^nextpow2(200));imagesc(abs(fftshift(Y)));

2-D fast Fourier transform - MATLAB fft2 (3)

Input Arguments

collapse all

XInput array
matrix | multidimensional array

Input array, specified as a matrix or a multidimensional array.If X is of type single, then fft2 nativelycomputes in single precision, and Y is also oftype single. Otherwise, Y isreturned as type double.

Data Types: double | single | int8 | int16 | int32 | uint8 | uint16 | uint32 | logical
Complex Number Support: Yes

mNumber of transform rows
positive integer scalar

Number of transform rows, specified as a positive integer scalar.

Data Types: double | single | int8 | int16 | int32 | uint8 | uint16 | uint32 | logical

nNumber of transform columns
positive integer scalar

Number of transform columns, specified as a positive integerscalar.

Data Types: double | single | int8 | int16 | int32 | uint8 | uint16 | uint32 | logical

More About

collapse all

2-D Fourier Transform

This formula defines the discrete Fourier transform Y ofan m-by-n matrix X:

Yp+1,q+1=j=0m1k=0n1ωmjpωnkqXj+1,k+1

ωm and ωn arecomplex roots of unity:

ωm=e2πi/mωn=e2πi/n

i is the imaginary unit. p and j areindices that run from 0 to m–1, and q and k areindices that run from 0 to n–1. This formulashifts the indices for X and Y by1 to reflect matrix indices in MATLAB®.

Extended Capabilities

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

Version History

Introduced before R2006a

See Also

fft | fftn | fftw | ifft2

2-D fast Fourier transform - MATLAB fft2 (2024)
Top Articles
Latest Posts
Article information

Author: Melvina Ondricka

Last Updated:

Views: 6132

Rating: 4.8 / 5 (68 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Melvina Ondricka

Birthday: 2000-12-23

Address: Suite 382 139 Shaniqua Locks, Paulaborough, UT 90498

Phone: +636383657021

Job: Dynamic Government Specialist

Hobby: Kite flying, Watching movies, Knitting, Model building, Reading, Wood carving, Paintball

Introduction: My name is Melvina Ondricka, I am a helpful, fancy, friendly, innocent, outstanding, courageous, thoughtful person who loves writing and wants to share my knowledge and understanding with you.