FFT长度会影响滤波精度吗?
我正在设计一个分数延迟滤波器,我的 5 h(n) 阶拉格朗日系数在时域中有 6 个抽头。我已经测试过使用 matlab 将 h(n) 与 x(n) (5000 个采样信号)进行卷积,结果看起来不错。当我尝试使用 FFT 和 IFFT 方法时,输出完全错误。实际上,我的 FFT 是用频域中的 8192 个数据计算的,这是 5000 个信号样本最接近的 2 的幂。对于 IFFT 部分,我将 8192 频域数据转换回时域中的 5000 长度数据。所以,问题是,为什么这个东西在卷积中起作用,但在 FFT 乘法中不起作用。将频域中的 6 个抽头 h(n) 转换为 8192 个抽头是否会导致此问题?
实际上,我尝试过使用重叠保存方法,该方法用较小的 x(n) 块执行 FFT 和乘法,并分别执行 5 次。结果似乎比之前的稍微好一些,至少我可以看到波形模式,但仍然略有失真。因此,知道哪里出了问题,以及解决方案是什么。谢谢。
我在频域而不是时域实现循环卷积的原因是,我尝试将拉格朗日滤波器与频域中的其他低通滤波器合并,以便实现更有效。当然,我确实相信在频域中实现滤波将比在时域中实现卷积快得多。 LP 滤波器在时域中有 120 个抽头。由于内存限制,包括填充在内的原始数据的长度将限制为 1024,fft bin 也是如此。
因为我的拉格朗日系数只有 6 个抽头,这与 1024 个抽头有很大的不同。我怀疑频域中 6 个抽头到 1024 个 bin 的 fft 会导致错误。这是我仅关于拉格朗日滤波器的 matlab 代码。这只是测试代码,不是实现代码。有点乱,抱歉。如果您能给我关于这个问题的更多建议,我将非常感激。谢谢。
t=1:5000;
fs=2.5*(10^12);
A=70000;
x=A*sin(2*pi*10.*t.*(10^6).*t./fs);
delay=0.4;
N=5;
n = 0:N;
h = ones(1,N+1);
for k = 0:N
index = find(n ~= k);
h(index) = h(index) * (delay-k)./ (n(index)-k);
end
pad=zeros(1,length(h)-1);
out=[];
H=fft(hh,1024);
H=fft([h zeros(1,1024-length(h))]);
for i=0:1:ceil(length(x)/(1024-length(h)+1))-1
if (i ~= ceil(length(x)/(1024-length(h)+1))-1)
a=x(1,i*(1024-length(h)+1)+1:(i+1)*(1024-length(h)+1));
else
temp=x(1,i*(1024-length(h)+1)+1:length(x));
a=[temp zeros(1,1024-length(h)+1-length(temp))];
end
xx=[pad a];
X=fft(xx,1024);
Y=H.*X;
y=abs(ifft(Y,1024));
out=[out y(1,length(h):length(y))];
pad=y(1,length(a)+1:length(y));
end
I am designing a fractional delay filter, and my lagrange coefficient of order 5 h(n) have 6 taps in time domain. I have tested to convolute the h(n) with x(n) which is 5000 sampled signal using matlab, and the result seems ok. When I tried to use FFT and IFFT method, the output is totally wrong. Actually my FFT is computed with 8192 data in frequency domain, which is the nearest power of 2 for 5000 signal sample. For the IFFT portion, I convert back the 8192 frequency domain data back to 5000 length data in time domain. So, the problem is, why this thing works in convolution, but not in FFT multiplication. Does converting my 6 taps h(n) to 8192 taps in frequency domain causes this problem?
Actually I have tried using overlap-save method, which perform the FFT and multiplication with smaller chunks of x(n) and doing it 5 times separately. The result seems slight better than the previous, and at least I can see the waveform pattern, but still slightly distorted. So, any idea where goes wrong, and what is the solution. Thank you.
The reason I am implementing the circular convolution in frequency domain instead of time domain is, I am try to merge the Lagrange filter with other low pass filter in frequency domain, so that the implementation can be more efficient. Of course I do believe implement filtering in frequency domain will be much faster than convolution in time domain. The LP filter has 120 taps in time domain. Due to the memory constraints, the raw data including the padding will be limited to 1024 in length, and so with the fft bins.
Because my Lagrange coefficient has only 6 taps, which is huge different with 1024 taps. I doubt that the fft of the 6 taps to 1024 bins in frequency domain will cause error. Here is my matlab code on Lagrange filter only. This is just a test code only, not implementation code. It's a bit messy, sorry about that. Really appreciate if you can give me more advice on this problem. Thank you.
t=1:5000;
fs=2.5*(10^12);
A=70000;
x=A*sin(2*pi*10.*t.*(10^6).*t./fs);
delay=0.4;
N=5;
n = 0:N;
h = ones(1,N+1);
for k = 0:N
index = find(n ~= k);
h(index) = h(index) * (delay-k)./ (n(index)-k);
end
pad=zeros(1,length(h)-1);
out=[];
H=fft(hh,1024);
H=fft([h zeros(1,1024-length(h))]);
for i=0:1:ceil(length(x)/(1024-length(h)+1))-1
if (i ~= ceil(length(x)/(1024-length(h)+1))-1)
a=x(1,i*(1024-length(h)+1)+1:(i+1)*(1024-length(h)+1));
else
temp=x(1,i*(1024-length(h)+1)+1:length(x));
a=[temp zeros(1,1024-length(h)+1-length(temp))];
end
xx=[pad a];
X=fft(xx,1024);
Y=H.*X;
y=abs(ifft(Y,1024));
out=[out y(1,length(h):length(y))];
pad=y(1,length(a)+1:length(y));
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一些评论:
Some comments: