dsp.IFFT - Inverse discrete Fourier transform (IDFT) - MATLAB (original) (raw)
Inverse discrete Fourier transform (IDFT)
Description
The dsp.IFFT
System object™ computes the inverse discrete Fourier transform (IDFT) of the input. The object uses one or more of the following fast Fourier transform (FFT) algorithms depending on the complexity of the input and whether the output is in linear or bit-reversed order:
- Double-signal algorithm
- Half-length algorithm
- Radix-2 decimation-in-time (DIT) algorithm
- Radix-2 decimation-in-frequency (DIF) algorithm
- An algorithm chosen from FFTW [1], [2]
The dsp.IFFT
object and the ifft function both compute the inverse discrete Fourier transform (IDFT) of the input. However, the object can process large streams of real-time data and handle system states automatically. The function performs one-time computations on data that is readily available and cannot handle system states. For a comparison between the two, see System Objects vs MATLAB Functions.
To compute the IFFT of the input:
- Create the
dsp.IFFT
object and set its properties. - Call the object with arguments, as if it were a function.
To learn more about how System objects work, see What Are System Objects?
Creation
Syntax
Description
`ift` = dsp.IFFT
returns an IFFT
object, ift
, that computes the IDFT of a column vector or _N_-D array. For column vectors or N-D arrays, theIFFT
object computes the IDFT along the first dimension of the array. If the input is a row vector, the IFFT
object computes a row of single-sample IDFTs and issues a warning.
`ift` = dsp.IFFT(`Name,Value`)
returns an IFFT
object, ift
, with each property set to the specified value. Enclose each property name in single quotes. Unspecified properties have default values.
Properties
Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and therelease function unlocks them.
If a property is tunable, you can change its value at any time.
For more information on changing property values, seeSystem Design in MATLAB Using System Objects.
Specify the implementation used for the FFT as Auto
,Radix-2
, or FFTW
. When you set this property toRadix-2
, the FFT length must be a power of two.
Set this property to true
if the order of Fourier transformed input elements to the IFFT
object are in bit-reversed order. The default is false
, which denotes linear ordering.
Dependencies
This property applies only when the FFTLengthSource
property is Auto
.
Set this property to true
if the input is conjugate symmetric to yield real-valued outputs. The discrete Fourier transform of a real valued sequence is conjugate symmetric, and setting this property to true
optimizes the IDFT computation method. Setting this property to false
for conjugate symmetric inputs may result in complex output values with nonzero imaginary parts. This occurs due to rounding errors. Setting this property to true
for nonconjugate symmetric inputs results in invalid outputs.
Dependencies
This property applies only when the FFTLengthSource
property is Auto
.
Specify whether to divide the IFFT output by the FFT length. The default istrue
and each element of the output is divided by the FFT length.
Specify how to determine the FFT length as Auto
orProperty
. When you set this property to Auto
, the FFT length equals the number of rows of the input signal.
Dependencies
This property applies only when both the BitReversedInput
andConjugateSymmetricInput
properties arefalse
.
Specify the FFT length as an integer greater than or equal to 2.
This property must be a power of two if any of these conditions apply:
- The input is a fixed-point data type.
- The FFTImplementation property is
Radix-2
.
Dependencies
This property applies when you set the BitReversedInput
andConjugateSymmetricInput
properties to false
, and the FFTLengthSource
property to'Property'
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Wrap input data when FFTLength
is shorter than input length. If this property is set to true, modulo-length data wrapping occurs before the FFT operation, given FFTLength
is shorter than the input length. If this property is set to false, truncation of the input data to theFFTLength
occurs before the FFT operation.
Fixed-Point Properties
Specify the rounding method.
Specify the overflow action as Wrap
orSaturate
.
Specify the sine table data type as Same word length as input
or Custom
.
Specify the sine table fixed-point type as an unscaled numerictype (Fixed-Point Designer) object with a Signedness
ofAuto
.
Dependencies
This property applies when you set the SineTableDataType
property to Custom
.
Specify the product data type as Full precision
, Same as input
, or Custom
.
Specify the product fixed-point type as a scaled numerictype (Fixed-Point Designer) object with a Signedness
ofAuto
.
Dependencies
This property applies when you set the ProductDataType
property to Custom
.
Specify the accumulator data type as Full precision
,Same as input
, Same as product
, orCustom
.
Specify the accumulator fixed-point type as a scaled numerictype (Fixed-Point Designer) object with a Signedness
ofAuto
.
Dependencies
This property applies when you set the AccumulatorDataType
property to Custom
.
Specify the output data type as Full precision
, Same as input
, or Custom
.
Specify the output fixed-point type as a scaled numerictype (Fixed-Point Designer) object with a Signedness
ofAuto
.
Dependencies
This property applies when you set the OutputDataType
property to Custom
.
Usage
Syntax
Description
[y](#d126e304430) = ift([x](#d126e304340))
computes the inverse discrete Fourier transform (IDFT) , y
, of the inputx
along the first dimension of x
.
Input Arguments
Data input, specified as a vector, matrix, or _N_-D array.
When the FFTLengthSource
property isAuto
, the length of x
along the first dimension must be a positive integer power of two. When the FFTLengthSource
property is 'Property'
, the length ofx
along the first dimension can be any positive integer and theFFTLength
property must be a positive integer power of two.
Variable-size input signals are only supported when theFFTLengthSource
property is set to'Auto'
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fi
Complex Number Support: Yes
Output Arguments
Inverse discrete Fourier transform of input signal, returned as a vector, matrix, or _N_-D array.
When FFTLengthSource
property is set to'Auto'
, the FFT length is same as the number of rows in the input signal. When FFTLengthSource
property is set to'Property'
, the FFT length is specified through theFFTLength
property.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fi
Complex Number Support: Yes
Object Functions
To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj
, use this syntax:
step | Run System object algorithm |
---|---|
release | Release resources and allow changes to System object property values and input characteristics |
reset | Reset internal states of System object |
Examples
Compute the FFT of a noisy sinusoidal input signal. The energy of the signal is stored as the magnitude square of the FFT coefficients. Determine the FFT coefficients which occupy 99.99% of the signal energy and reconstruct the time-domain signal by taking the IFFT of these coefficients. Compare the reconstructed signal with the original signal.
Consider a time-domain signal x[n], which is defined over the finite time interval 0≤n≤N-1. The energy of the signal x[n] is given by the following equation:
EN = ∑n=0N-1|x[n]|2
FFT coefficients, X[k], are considered signal values in the frequency domain. The energy of the signal x[n] in the frequency-domain is therefore the sum of the squares of the magnitude of the FFT coefficients:
EN = 1N∑k=0N-1|X[k]|2
According to Parseval's theorem, the total energy of the signal in time or frequency-domain is the same.
EN = ∑n=0N-1|x[n]|2 = 1N∑k=0N-1|X[k]|2
Initialization
Initialize a dsp.SineWave
System object to generate a sine wave sampled at 44.1 kHz and has a frequency of 1000 Hz. Construct a dsp.FFT
and dsp.IFFT
objects to compute the FFT and the IFFT of the input signal.
The FFTLengthSource
property of each of these transform objects is set to "Auto"
. The FFT length is hence considered as the input frame size. The input frame size in this example is 1020, which is not a power of 2, so select the FFTImplementation
as "FFTW"
.
L = 1020; Sineobject = dsp.SineWave(SamplesPerFrame=L,... PhaseOffset=10,... SampleRate=44100,... Frequency=1000); ft = dsp.FFT(FFTImplementation="FFTW"); ift = dsp.IFFT(FFTImplementation="FFTW",... ConjugateSymmetricInput=true); rng(1);
Streaming
Stream in the noisy input signal. Compute the FFT of each frame and determine the coefficients that constitute 99.99% energy of the signal. Take IFFT of these coefficients to reconstruct the time-domain signal.
numIter = 1000; for Iter = 1:numIter Sinewave1 = Sineobject(); Input = Sinewave1 + 0.01*randn(size(Sinewave1)); FFTCoeff = ft(Input); FFTCoeffMagSq = abs(FFTCoeff).^2;
EnergyFreqDomain = (1/L)*sum(FFTCoeffMagSq);
[FFTCoeffSorted, ind] = sort(((1/L)*FFTCoeffMagSq),...
1,"descend");
CumFFTCoeffs = cumsum(FFTCoeffSorted);
EnergyPercent = (CumFFTCoeffs/EnergyFreqDomain)*100;
Vec = find(EnergyPercent > 99.99);
FFTCoeffsModified = zeros(L,1);
FFTCoeffsModified(ind(1:Vec(1))) = FFTCoeff(ind(1:Vec(1)));
ReconstrSignal = ift(FFTCoeffsModified);
end
99.99% of the signal energy can be represented by the number of FFT coefficients given by Vec(1)
:
The signal is reconstructed efficiently using these coefficients. If you compare the last frame of the reconstructed signal with the original time-domain signal, you can see that the difference is very small and the plots match closely.
max(abs(Input-ReconstrSignal))
plot(Input,"*"); hold on; plot(ReconstrSignal,"o"); hold off;
Algorithms
This object implements the algorithm, inputs, and outputs described on the IFFT block reference page. The object properties correspond to the block parameters, except the Output sampling mode parameter is not supported bydsp.IFFT
.
References
[2] Frigo, M. and S. G. Johnson, “FFTW: An Adaptive Software Architecture for the FFT,” Proceedings of the International Conference on Acoustics, Speech, and Signal Processing, Vol. 3, 1998, pp. 1381-1384.
Extended Capabilities
Usage notes and limitations:
- See System Objects in MATLAB Code Generation (MATLAB Coder).
- When the following conditions apply, the executable generated from this System object relies on prebuilt dynamic library files (
.dll
files) included with MATLAB®:FFTImplementation
is set to'FFTW'
.FFTImplementation
is set to'Auto'
,FFTLengthSource
is set to'Property'
, andFFTLength
is not a power of two.
Use thepackNGo
function to package the code generated from this System object and all the relevant files in a compressed zip file. Using this zip file, you can relocate, unpack, and rebuild your project in another development environment where MATLAB is not installed. For more details, see How To Run a Generated Executable Outside MATLAB.
- When the FFT length is a power of two, you can generate standalone C and C++ code from this System object.
Version History
Introduced in R2012a