ssa
1package oss2
3import (4"math"5"strconv"6
7"github.com/xuri/excelize/v2"8)
9
10func Make_singnal(n int) []float64 {11waveform := make([]float64, n)12for index := range waveform {13waveform[index] = F(float64(index), n)14//waveform[index] += math.Cos(2 * math.Pi * 0.03 * float64(index))15//waveform[index] += 0.8 * math.Cos(2*math.Pi*(0.06*float64(index)+0.09/(2.0*float64(n))*float64(index)*float64(index)))16}17return waveform18}
19func Make_singnal_xn(filename string) ([]float64, int) {20f, _ := excelize.OpenFile(filename + ".xlsx")21cells, _ := f.GetRows("main")22a := make([]float64, len(cells))23
24for i := 0; i < len(cells); i++ {25b, _ := strconv.ParseFloat(cells[i][0], 64)26a[i] = b27}28
29return a, len(cells)30}
31func F(x float64, n int) float64 {32var waveX float6433waveX = math.Cos(2 * math.Pi * 0.03 * x)34waveX += 0.8 * math.Cos(2*math.Pi*(0.06*x+0.09/(2.0*float64(n))*x*x))35return waveX36}
37