Main Content

dsp.FFT

Discrete Fourier transform

Description

dsp.FFTSystem object™ computes the discrete Fourier transform (DFT) of an input using fast Fourier transform (FFT). 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:

  • 双信号算法

  • Half-length algorithm

  • radix-2decimation-in-time (DIT) algorithm

  • radix-2decimation-in-frequency (DIF) algorithm

  • An algorithm chosen from FFTW[[1这是给予的,,,,[2]

To compute the DFT of an input:

  1. Create thedsp.FFTOBJect and set its properties.

  2. Call the object with arguments, as if it were a function.

要了解有关系统对象如何工作的更多信息,请参阅What Are System Objects?

Creation

Description

英尺=dsp.FFT返回aFFTOBJect,英尺,,,,that computes the DFT of ann-d数组。对于列向量或多维阵列FFTOBJect computes the DFT along the first dimension. If the input is a row vector, theFFTOBJect computes a row of single-sample DFTs and issues a warning.

例子

英尺= dsp.fft(名称,价值返回aFFTOBJect with each specified property set to the specified value. Enclose each property name in single quotes. Unspecified properties have default values.

Properties

expand all

Unless otherwise indicated, properties arenontunable,,,,which means you cannot change their values after calling the object. Objects lock when you call them, and the发布function unlocks them.

If a property istunable,您可以随时更改其价值。

For more information on changing property values, see使用系统对象在MATLAB中的系统设计

指定用于FFT的实现为Auto,,,,radix-2,,,,orFFTW。When you set this property toradix-2,,,,the FFT length must be a power of two.

指定输出通道元素相对于输入元素的顺序。将此属性设置为true输出频率指数bit-reversed或der. The default is错误的,对应于频率指数的线性排序。

将此属性设置为true如果FFT的输出应除以FFT长度。当您希望FFT的输出保持与输入相同的幅度范围时,此选项很有用。当使用定点数据类型时,这特别有用。

这default value of this property is错误的with no scaling.

Specify how to determine the FFT length asAutoor财产。When you set this property toAuto,,,,the FFT length equals the number of rows of the input signal.

FFT length, specified as an integer greater than or equal to 2.

This property must be a power of two if any of these conditions apply:

Dependencies

This property applies when you set thefftlengthsource财产为财产

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

裹input data when FFT length is shorter than input length. If this property is set to true, modulo-length data wrapping occurs before the FFT operation, given FFT length is shorter than the input length. If this property is set to false, truncation of the input data to the FFT length occurs before the FFT operation.

Fixed-Point Properties

Specify the rounding method.

将溢出操作指定为orSaturate

Specify the sine table data type as与输入相同的单词长度orCustom

将正弦表定义点类型指定为未量的numerictype(Fixed-Point Designer)带有A的对象SignednessofAuto

Dependencies

This property applies when you set theSinetabledatate财产为Custom

将产品数据类型指定为Full precision,,,,Same as input,,,,orCustom

Specify the product fixed-point type as a scalednumerictype(Fixed-Point Designer)带有A的对象SignednessofAuto

Dependencies

This property applies when you set theProductDatatype财产为Custom

Specify the accumulator data type asFull precision,,,,Same as input,,,,与产品相同,,,,orCustom

将累加器定义点类型指定为缩放numerictype(Fixed-Point Designer)带有A的对象SignednessofAuto

Dependencies

This property applies when you set the累积财产为Custom

Specify the output data type as one ofFull precision,,,,Same as input,,,,Custom

Specify the output fixed-point type as a scalednumerictype(Fixed-Point Designer)带有A的对象SignednessofAuto

Dependencies

This property applies when you set theOutputDataType财产为Custom

用法

句法

Description

例子

y=英尺(Xcomputes the DFT,y,,,,of the inputX沿着第一维X

输入参数

expand all

Time-domain input signal, specified as a vector, matrix, orn-d数组。

When thefftlengthsourceproperty is set to'Auto',长度Xalong the first dimension must be a positive integer power of two. This length is also the FFT length. When thefftlengthsourceproperty is'Property',您指定的价值FFTLengthproperty must be a positive integer power of two.

仅在金宝appfftlengthsourceproperty is set to'Auto'

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64|fi
复杂的数字支持:金宝appYes

Output Arguments

expand all

Discrete Fourier transform of input signal, returned as a vector, matrix, or ann-d数组。Whenfftlengthsourceproperty is set to'Auto',,,,the FFT length is same as the number of rows in the input signal. Whenfftlengthsourceproperty is set to'Property',,,,the FFT length is specified through theFFTLength财产。

To support non-power-of-two transform lengths with variable-size data, set thefftimplation财产为'FFTW'

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64|fi
复杂的数字支持:金宝appYes

对象功能

要使用对象函数,请将系统对象指定为第一个输入参数。例如,释放名称的系统对象的系统资源OBJ,,,,use this syntax:

释放(OBJ)

expand all

step RunSystem object算法
发布 释放资源并允许更改System object属性值和输入特征
reset Reset internal states ofSystem object

eXamples

全部收缩

Find frequency components of a signal in additive noise.

笔记:This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalentstep句法。例如,myObject(x) becomes step(myObject,x).

Fs = 800; L = 1000; t = (0:L-1)'/Fs; x = sin(2*pi*250*t) + 0.75*cos(2*pi*340*t); y = x + .5*randn(size(x));% noisy signal英尺= dsp.fft('FFTLengthSource',,,,'Property',,,,。。。“ fftlength”,,,,1024); Y = ft(y);

Plot the single-sided amplitude spectrum

plot(Fs/2*linspace(0,1,512), 2*abs(Y(1:512)/1024)) title('嘈杂信号y(t)的单面振幅光谱'')Xlabel(“频率(Hz)”);ylabel('|Y(f)|'

图包含一个轴对象。带有标题单面振幅频谱的轴对象噪声信号y(t)包含一个类型线的对象。

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.

笔记If you are using R2016a or an earlier release, replace each call to the object with the equivalentstep句法。例如,OBJ(x)becomesstep(obj(x))

考虑时间域信号 X [[ n 这是给予的 ,,,,which is defined over the finite time interval 0 n n - 1 。信号的能量 X [[ n 这是给予的 is given by the following equation:

e n = n = 0 n - 1 | X [[ n 这是给予的 | 2

FFT系数, X [[ k 这是给予的 在频域中被视为信号值。信号的能量 X [[ n 这是给予的 in the frequency-domain is therefore the sum of the squares of the magnitude of the FFT coefficients:

e n = 1 n k = 0 n - 1 | X [[ k 这是给予的 | 2

According to Parseval's theorem, the total energy of the signal in time or frequency-domain is the same.

e n = n = 0 n - 1 | X [[ n 这是给予的 | 2 = 1 n k = 0 n - 1 | X [[ k 这是给予的 | 2

Initialization

Initialize adsp.SineWave系统对象生成以44.1 kHz采样的正弦波,频率为1000 Hz。构造dsp.FFTanddsp.IFFT对象计算输入信号的FFT和IFFT。

'FFTLengthSource'property of each of these transform objects is set to'Auto'。因此,FFT长度被认为是输入帧大小。此示例中的输入框架大小为1020,这不是2个功率,因此请选择'FFTImplementation'作为'FFTW'

L = 1020;SineObject = DSP.SineWave(“ SampleSperFrame”,,,,L,。。。'PhaseOffset',,,,10,,,,。。。'SampleRate',44100,。。。'Frequency',,,,1000);英尺= dsp.fft('FFTImplementation',,,,'FFTW');ift = dsp.IFFT('FFTImplementation',,,,'FFTW',,,,。。。'ConjugateSymmetricInput',真的);RNG(1);

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;为了iter = 1:numiter sinewave1 = sineObject();输入= SineWave1 + 0.01*randn(size(sinewave1));fftCoeff = ft(输入);fftCoeffmagsq = abs(fftCoeff)。^2;EnergyFreqDomain =(1/L)*sum(fftCoeffmagsq);[fftCoeffsorted,ind] = stort((((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);结尾

99.99%的信号能可以由FFT系数的数量表示VEC(1)

VEC(1)
ans = 296

这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(输入reconstrsignal))
ANS = 0.0431
plot(Input,'*');holdon;plot(ReconstrSignal,'o');holdoff;

图包含一个轴对象。轴对象包含2个类型行的对象。

Algorithms

This object implements the algorithm, inputs, and outputs described on theFFTblock reference page. The object properties correspond to the block parameters.

References

[1] FFTW(https://www.fftw.org

[2] Frigo,M。和S. G. Johnson,“ FFTW:FFT的自适应软件体系结构”,国际声学,语音和信号处理会议论文集,,,,Vol. 3, 1998, pp. 1381-1384.

eXtended Capabilities

版本历史记录

Introduced in R2012a

也可以看看

对象