![18L 18L]()
Then we need to call res, passing the timeseries as x, the number of harmonics as n and the upsampling (so we plot points in time beside the original ones) as up.png("res_18.png")res = nff(x = y, n = 18L, up = 100L, col = 2L)dev.off()要获得5至18次谐波之和,只是序列之间的差异To get the sum of the 5th to the 18th harmonics it's simply a difference between seriessum5to18 = nff(x = y, n = 18L, up = 10L, plot = FALSE)sum5to18$y = sum5to18$y - nff(x = y, n = 4L, up = 10L, plot = FALSE)$ypng("sum5to18.png")plot(sum5to18, pch = 16L, xlab = "Time", ylab = "Measurement", main = "5th to 18th harmonics sum", type = "l", col = 2)dev.off()添加参数add和col允许我们绘制具有特定颜色的多条波浪Adding the arguments add and col allow us to plot multiple waves as well, with specific colorscolors = rainbow(36L, alpha = 0.3)nff(x = y, n = 36L, up = 100L, col = colors[1])png("all_waves.png")for(i in 1:18){ ad = ifelse(i == 1, FALSE, TRUE) nff(x = y, n = i, up = 100L, col = colors[i], add = ad, main = "All waves up to 18th harmonic")}dev.off() 有没有办法提取每个系列的数据,然后另存为csv文件.因此,在此示例中,我应该为18个波形设置18个csv文件. Is there a way so extract the data of each series then save as a csv file. So in this example, I should have 18 csv files for the 18 waves.我编辑了代码,以允许谐波为0(基本上是平均值),因此现在您将单独的波提取为:I edited the code to allow a 0 harmonic (basically a mean), so now you extract the separate waves as:sep = array(data = NA_real_, dim = c(7300L, 2 + 18), dimnames = list(NULL, c("t", paste0("H", 0:18))))sep[,1:2] = as.matrix(nff(x = y, n = 0, up = 100L, plot = FALSE))for(i in 1:18L){ sep[,i+2] = nff(x = y, n = i, up = 100L, plot = FALSE)$y - nff(x = y, n = i-1, up = 100L, plot = FALSE)$y}然后,您可以使用write.table编写一个csv文件.Then you can use write.table to write a csv file. 这篇关于对R中的时间序列执行傅立叶分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-20 09:47