How do I perform fft in MATLAB without inbuilt function?
Why wouldn't you want to use the inbuilt function?
Otherwise - write your own.
- Define a function called fft
- Google/work out how an fft is performed (here seems a good start)
- Transcribe that algorithm into your function
- Call your new function
I'm not entirely sure what benefit that gives you over the inbuilt method, but there you go.
This is a function which performs a discrete Fourier transform (greatest accuracy is achieved with the highest N)
- function X = dft(x,N)
- %fast Fourier transform
- X = zeros(1,length(X));
- k=1;
- while k<length(X);
- n=0;
- tempSum=0;
- while n<N
- tempSum = tempSum + x(n)*exp(-1i * 2*pi*k*n/N);
- n=n+1;
- X(k) =tempSum;
- k=k+1;
To make it a fast Fourier transform, you need to work out which bits you can shave off, or what bits you can reuse.
I leave that as an exercise to the reader….
(But here's a hint….someone has already gone through all of that bother for you….it's called the inbuilt method)
For any help- MATLABSolutions
Comments
Post a Comment