7
"github.com/mjibson/go-dsp/fft"
8
"github.com/xuri/excelize/v2"
11
func TestFFT(t *testing.T) {
12
x := loadXlsx("fft_test.xlsx")
13
fft_signal := fft.FFTReal(x)
14
safeToXlsx3("fft_test.xlsx", fft_signal)
18
func loadXlsx(filename string) []float64 {
19
output := make([]float64, 0)
21
file_graph, _ := excelize.OpenFile(filename, excelize.Options{})
22
defer file_graph.Close()
24
rows, err := file_graph.GetRows("input")
29
for _, row := range rows {
31
n, err := strconv.ParseFloat(row[0], 64)
33
output = append(output, n)
40
func safeToXlsx3(filename string, y []complex128) {
41
file_graph, _ := excelize.OpenFile(filename, excelize.Options{})
42
defer file_graph.Close()
44
for ind := 0; ind < lenFor; ind++ {
47
file_graph.SetCellValue("output", "A"+strconv.Itoa(ind+1), y[ind])
48
file_graph.SetCellValue("output", "B"+strconv.Itoa(ind+1), real(y[ind]))
49
file_graph.SetCellValue("output", "C"+strconv.Itoa(ind+1), imag(y[ind]))