Can someone post the VBA code for the Fast Fourier Transform (FFT).
I need to rewrite it to do datasets larger than 4096 (Excel FFT is limited).
Looking for the same complex outputs that the built-in function provides.
Thanks in advance
Can someone post the VBA code for the Fast Fourier Transform (FFT).
I need to rewrite it to do datasets larger than 4096 (Excel FFT is limited).
Looking for the same complex outputs that the built-in function provides.
Thanks in advance
Last edited by gth826a; 09-18-2017 at 11:09 AM.
Want to get your question answered quickly?
- Ensure your question is not too vague. Don't assume anyone is familiar with your problem. While you can upload small attachments, describe your problem in the body of the post. We are fortunate to have several Excel gurus, but few mind-readers.
- On the other hand, skip irrelevant details. Be descriptive and concise. Short, direct, and to-the-point questions with apt thread titles are almost always answered promptly.
- Keep the scope reasonably narrow. Questions like, "How do I set up an accounting system in Excel?" might be a long time waiting.
- Explain what you've already tried. ("Calculation is set to automatic, but formulas still don't compute") so helpers don't waste your time or theirs.
- Post a WORKBOOK. Nobody wants to type data from a picture or paste text from your post into a spreadsheet as a prelude to helping. To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.
- If your question has not been answered within a day, consider adding another post with any additional information you believe is relevant. If you think your post is good as is, just reply to your own thread with the words "Bump no response", which will bring it to the top of the forum.
Ben Van Johnson
Google gave me this
https://stackoverflow.com/questions/...ing-excels-vba
i didn't look at the detail - but he seems to be asking for the same reason and have found a solution that he was happy with at the bottom.
If you want something done right... find a forum and ask an online expert.
Time flies like an arrow. Fruit flies like a banana.
The above link from the Google search shows coding that uses WorkSheetFunctions (.Complex, .ImSum, .ImProduct, etc.)...
I'm looking for some version of raw code where every calculation is done within the same macro/script.
Or, I would settle for some code/psuedo code that walks me through the "real" & "imaginary" calculations as computed by Excel.
I have created the following code:
Where FnCmplx is a 2D array of size (N-1,1) ... since the indexing starts at 0, and the array base is 0Please Login or Register to view this content.
i.e. for frequency kk=0, FnCmplx(0,0) = real number and FnCmplx(0,1) = imaginary number
However, when testing the script on a 4096 point data range - I have been unable to replicated the values that Excel produces.
I realize that my code above is not the FFT version of O(Nlog(N)) computations, but is instead the DFT expanded O(N^2) computations version...
But, the outputs should still be the same, correct??
Last edited by gth826a; 09-18-2017 at 10:26 AM.
If you are amenable to a formula-based solution, see attached. I expect it will get painfully slow with that many points.
Entia non sunt multiplicanda sine necessitate
I have yet to look at the file shg provided, but I was able to find the solution (below) using the slower DFT variation.
I was incorrect to multiply the summations by (1/N), and [although I didn't computer how big of a difference it made overall] VBA was miscalculating the Cos(2*pi*k*n/N) in some instances by .0000132262629816138 for integer-values of Pi.
The miscalculation was rectified by using the Round() function, and the comparison to Excel outputs was done using an N=4096 dataset.
As shg alluded to, the computation [on a Surface Pro3] takes several seconds at N=4096.Please Login or Register to view this content.
However, since my data sampling is logged on an interval of every 15 seconds - the calculation time for the DFT method is acceptable.
Maybe you should use a more accurate representation of pi than
Please Login or Register to view this content.
Touche, Sir! Touche.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks