View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Dana DeLouis Dana DeLouis is offline
external usenet poster
 
Posts: 947
Default Fourier, numbers-as-text, and macros.

Hi. This is a shorter / modified version of something I use.
Maybe you can get some ideas here.

Take the inverse of the data, and output it beginning at E1.
Note that you are assuming the data will be integers. This may not be
the case. You may be able to adjust it to your situation.
(with integer output, are you doing convolution, or high-precision
multiplication ?? )

Sub YourRoutine()
Call FFTInverse([C1:C16], [E1])
End Sub

Sub FFTInverse(InData, OutCell)
Dim N
Dim Cell

N = InData.Cells.Count
OutCell.Resize(N).Clear

Run "ATPVBAEN.XLAM!Fourier", InData, OutCell, True, False

For Each Cell In OutCell.Resize(N).Cells
Cell.Value = CDbl(WorksheetFunction.ImAbs(Cell))
Next Cell
End Sub

= = = = =
HTH
Dana DeLouis




Neal Carron wrote:
Dana,
All true, but I don't see how to apply your method to a column.
It seems I'd have to create a temporary column B, evaluate the FT in it, and
then set another column =ImReal(B1) as the final answer.
Is that what you meant?
- Neal

"Dana DeLouis" wrote:

Hi. The output is a complex number represented in Excel as a string.
=Complex(5,0) will show up as 5, but as a string, much like you are seeing.

=ImReal(B1) will return the Real part.

Due to 'rounding issues', you may prefer to use
IMABS(B1) is you believe the Complex part is suppose to be zero.

The advantage also is that it will convert those cells that do have very
small imaginary parts.

HTH
Dana DeLouis



Neal Carron wrote:
The output of the Fourier Transform fills most cells as numbers (all those
that are complex numbers), but all those that are real it fills as text(!)
The output of the inverse Fourier Transform fills all cells with
numbers-as-text(!)
My output column is formatted to Number, General. But the inverse FT result
is still written as text (they are all real numbers).
I need them as bonafide numbers (to be plotted).
Converting them to numbers is done by selecting the output cells, opening
the error icon on the upper left, and selecting "convert to number".
But this last action is not accepted when recording the strokes in a macro.

The steps suggested in HELP on "Convert numbers stored as text to numbers"
don't work.
So:
Can the FT routine be set to enter results directly as numbers?
If not, how do I convert numbers-as-text to numbers in a Macro?
- Neal