Matlab / Octave:使用FIR进行插值可得到按比例缩小的信号

时间:2017-11-22 04:41:27

标签: matlab filter signal-processing octave

给定x(n),它被上采样4倍,我想用下面的代码插值:

pkg load signal;
n = [1:100];
x = n.*cos(n);
upsampled = upsample(x,4);
b = fir1(30,0.25,'low');
interpolated = filter(b,1,upsampled)(16:end);
figure;
stem([1:4:400],x);
hold on;
stem(interpolated);

情节是: enter image description here

其中原始x(n)为蓝色,插值为红色。

为什么插值信号按比例缩小?

这看起来更好:

pkg load signal;
n = [1:100];
x = n.*cos(n);
upsampled = upsample(x,4);
b = fir1(30,0.25,'low');
interpolated = filter(b,1,upsampled)(16:end);
figure;
stem([1:4:400],x);
hold on;
stem(interpolated*4); %notice the multiplication by 4 here

enter image description here

但为什么会这样呢?或者我只是幸运?

1 个答案:

答案 0 :(得分:2)

我可以看到明确的相关性:

upsample(x,4)

stem(interpolated * 4)

upsample在变量的每对值之间插入3个零。因此,您的过滤器函数将生成一个平滑的结果。如果你的结果满足你,那很好。或者,尝试绕过这样的问题:

pkg load signal;
n = 1:100;
x = n .* cos(n);
b = fir1(30,0.25,'low');
interpolated = filter(b,1,x)(4:end);
final = upsample(interpolated,4);
figure;
stem([1:4:400],x);
hold on;
stem(final);