FFT WITHOUT Built-in functions

12 visualizaciones (últimos 30 días)
Camille Pham
Camille Pham el 7 de Mayo de 2022
Movida: DGM el 8 de En. de 2024
How do I write the matlab code for fourier transform without the built-in function (fft). NOT DFT! Decimation in time radix-2fft please!

Respuesta aceptada

Dyuman Joshi
Dyuman Joshi el 7 de Mayo de 2022
Editada: Dyuman Joshi el 7 de Mayo de 2022
Using the definition given at the end of FFT document
%x is your input
x=[1 2 3 4];
fft(x) %using for comparison
ans =
10.0000 + 0.0000i -2.0000 + 2.0000i -2.0000 + 0.0000i -2.0000 - 2.0000i
Method 1
%loop approach
for j=1:numel(x)
y(j)=sum(arrayfun(@(z) x(z)*exp(-i*2*pi*(j-1)*(z-1)/numel(x)),1:numel(x)));
end
y
y =
10.0000 + 0.0000i -2.0000 + 2.0000i -2.0000 - 0.0000i -2.0000 - 2.0000i
Method 2
%vector approach
l=length(x);
z = x*exp(-2j*pi/l*(0:l-1).'*(0:l-1))
z =
10.0000 + 0.0000i -2.0000 + 2.0000i -2.0000 - 0.0000i -2.0000 - 2.0000i
  2 comentarios
Camille Pham
Camille Pham el 7 de Mayo de 2022
Movida: DGM el 8 de En. de 2024
Without the fft built in function.
Dyuman Joshi
Dyuman Joshi el 7 de Mayo de 2022
@Camille Pham, y and z are obtained without using fft(), I just used fft() to show the comparison.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by