我正在尝试实现插值和抽取而不使用MATLAB的内置功能来实现此目的我遵循以下顺序
upsampling-> 滤波器 - > 处理冷杉过滤延迟
这三个步骤称为插值
滤波器 - >
处理冷杉过滤器延迟 - >
下采样
这三个步骤称为Decimation
在处理群延迟后的上述处理中,我的整体符号减少了,这就产生了恢复插值输入的相同数据的问题那么我该怎么办才能解决这个问题。
我的代码写在下面
idata=ones(1,100); %input symbols 100
nfilt=30;
upfac = 10;
alpha = 0.5;
xr = upsample(idata,upfac); %upconverted symbols which is 1000
h1 = intfilt(upfac,2,alpha);
y = filter(h1,1,xr);
delay = mean(grpdelay(h1));
y(1:delay) = []; %filter delay discarded 19 symbols are remaining symbols are 981
[B,A]=fir1(30,1/10);
dec_filter=filter(B,A,y); %down sample filter symbols are still 981
delay = mean(grpdelay(B));
dec_filter(1:delay) = []; %delay is 15 and after handling delay symbols reduced to 966
dec=downsample(dec_filter,upfac); %after down sample remaining symbols are 96
答案 0 :(得分:1)
您可以使用decimate function手动避免手动执行所有这些计算。鉴于您的上采样数据,您所要做的就是执行以下代码:
upfac = 10;
nfilt = 30;
idata = ones(1,100);
xr = upsample(idata,upfac);
dec = decimate(xr,upfac,nfilt,'fir');