gpt4 book ai didi

r - 在 FFT 噪声去除期间获取 y 轴偏移

转载 作者:行者123 更新时间:2023-12-04 12:33:00 25 4
gpt4 key购买 nike

我正在尝试通过 R 中的 FFT 去除噪声。我遇到的问题是在此过程中我得到了 y 轴偏移,我不确定原因是什么。我已经阅读了 FFT 并使用了 this resource as a guide .请参阅下面我一直在执行的代码以及结果的示例图形。这是指向 csv 文件的保管箱链接。 data.csv

data=read.csv('data.csv')
plot(data,type='l')

#FFT filtration function
fft.filter=function(data,threshold){
temp=fft(data)
temp[threshold:length(data)-threshold]=0+0i
temp=Re(fft(temp,inverse=TRUE)/length(temp))
return(temp)
}

data2=data
data2$Signal=fft.filter(data2$Signal,100)

未过滤的情节: enter image description here

过滤图: enter image description here

如图所示,数据缩放看起来不错,我只是得到了一个我认为不应该的转变。 FFT 函数正在努力消除序列中的噪声。

最佳答案

索引有问题。它是从 0 到 length(data)-threshold 的索引,而你想要 threshold:(length(data)-threshold) 我相信。将索引行更改为

temp[threshold:(length(data)-threshold)]=0+0i

关于r - 在 FFT 噪声去除期间获取 y 轴偏移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32359081/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com