Menghitung spektrum data seri waktu menggunakan FFT-Macro (Excel)

Dengan menggunakan fungsi FFT di Excel dan menggunakan Macro Excel, kita dapat menghitung spektrum dari data seri waktu (time series). Sintaks Macro nya dapat dilihat sbb:

———————— fft-macro ——————————

Sub uji()
Dim f(512), ff(512), A(512)
Application.Run “ATPVBAEN.XLAM!Fourier”, _
ActiveSheet.Range(“$B$2:$B$513”), _
ActiveSheet.Range(“$C$2:$C$513”), _
False, False

Range(“D3”).Select
Application.CutCopyMode = False

ActiveCell.FormulaR1C1 = “=IMREAL(RC[-1])”
Range(“D3”).Select
Selection.Copy
Range(“C3”).Select
Selection.End(xlDown).Select
Range(“D513”).Select
Range(Selection, Selection.End(xlUp)).Select
ActiveSheet.Paste
Cells(2, 5) = “period”
Cells(2, 6) = “PSD”

Cells(2, 7) = “period”
Cells(2, 8) = “PSD”

Cells(2, 9) = “period”
Cells(2, 10) = “PSD”
L = 252
For i = 1 To L
h = i
f(i) = h / L * 0.5
Cells(2 + i, 5) = 1 / f(i)
Cells(2 + i, 6) = Abs(Cells(2 + i, 4)) ^ 2 / L
Next
For i = 2 To L
If Cells(2 + i, 6) > Cells(1 + i, 6) Then
If Cells(2 + i, 6) > Cells(3 + i, 6) Then
Cells(2 + i, 7) = Cells(2 + i, 5)
Cells(2 + i, 8) = Cells(2 + i, 6)
End If
End If
Next
j = 1
For i = 2 To 255
If Cells(2 + i, 6) > Cells(1 + i, 6) Then
If Cells(2 + i, 6) > Cells(3 + i, 6) Then
Cells(2 + j, 9) = Cells(2 + i, 5)
Cells(2 + j, 10) = Cells(2 + i, 6)
j = j + 1
End If
End If
Next
End Sub

———————— fft-macro ——————————

Tampilan excel FFT-macro adalah sebagai berikut,

Dimana kolom B menunjukkan data seri hujan harian. Dengan menjalankan program macro ini maka akan didapat hasil berupa spektrum hujan.

Hasil uji FFT-Macro dapat dilihat pada gambar screen shoot berikut,

Gambar atas merupakan data seri hujan harian (domain waktu). Gambar di bawahnya merupakan spektrum hujan harian (domain frekuensi).

File program di atas dapat didownload dari Link ini.

Leave a Comment