声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2121|回复: 2

[FFT] interpolation in the time domain by zero Padding In The Frequency Domain

[复制链接]
发表于 2010-1-21 15:30 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
最近学习DSP时,在网上看到这样一个网页,作者也很出名,相信很多人都读过他的书, understanding digital signal processing
webpage title:

How to Interpolate in the Time-Domain by
Zero-Padding in the Frequency Domain
-by Rick Lyons

http://www.dspguru.com/dsp/howtos/how-to-interpolate-in-time-domain-by-zero-padding-in-frequency-domain

根据他描述的方法,我用matlab编程验证了一下,发现结果有些出入,不知问题出在哪里。因此贴在这里希望大家能够给予指点。

data-0.jpg


data.jpg

function test()
close all
clear all
clc;
dt=1/8e3;
df=1/dt;
N=7;
t=[0:1:N-1]*dt;
f1=1e3;
f2=2e3;
s(:,1)=sin(2*pi*f1*t)+0.5*sin(2*pi*f2*t+0.75*pi);
% s=s.*hanning(len);
S=fft(s);
f=[0:1:N-1]*df/N;
figure(1)
subplot(211)
plot(t,s,'-O');hold on
figure(2)
subplot(211)
plot(real(S),'Ob');hold on
subplot(212)
plot(imag(S),'sr');hold on
M=2*N;
if mod(N,2)==0
    Sm=[S(1:N/2);zeros(M/2,1); S(1+N/2); zeros(M/2,1);S(2+N/2:N)];
else
    Sm=[S(1:(N+1)/2);zeros(M,1);S((N+3)/2:N)];
end
figure(3)
subplot(211)
plot(real(Sm),'Ob');hold on
subplot(212)
plot(imag(Sm),'sr');hold on
sn=ifft(Sm);
Nn=length(sn);
Re_sn=real(sn)*(N+M)/N;
Im_sn=imag(sn)*(N+M)/N;
dt=max(t)/(M+N-1);
tn=[0:M+N-1]*dt;
figure(1)
subplot(211)
plot(tn,Re_sn,'-*r');hold on
grid on
legend('orginal data','interpolated data')

[ 本帖最后由 xinglong-liu 于 2010-1-21 15:41 编辑 ]
回复
分享到:

使用道具 举报

发表于 2010-1-21 16:48 | 显示全部楼层
程序基本上是对的,只是计算内插后的dt和tn不正确,把
dt=max(t)/(M+N-1);
tn=[0:M+N-1]*dt;
改为
dt=dt*N/(N+M);
tn=(0:N+M-1)*dt;
就能得到正确的结果了。

评分

1

查看全部评分

 楼主| 发表于 2010-1-21 20:41 | 显示全部楼层
谢谢songzy41的指点,终于得到了正确的结果!
还需要继续学习!
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-22 03:43 , Processed in 0.070489 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表