使用 sinc 函数重建数字信号

Reconstruction of Digital Signal using the sinc Function

我正在尝试使用 MATLAB 中的 sinc 函数以采样频率 800e6 重建信号 cos(2*pi*300e6)。当我输入以下代码时,我反而得到了一些非常嘈杂的东西——这不是我想要的。我究竟做错了什么?提前致谢!

代码:

F1 = 300e6;
Fs = 800e6;
tmin = 0;
tmax = 10/F1;
t = tmin:1e-12:tmax;
x1 = cos(2*pi*F1*t);
Ts = 1/Fs;
ts = tmin:Ts:tmax;
x1resampled = cos(2*pi*F1*ts);
x1reconstructed = zeros(1,length(t)); %preallocating for speed
samples = length(ts);
for i = 1:1:length(t)
    for n = 1:1:samples
        x1reconstructed(i) = sum(x1resampled(n)*sinc(pi*(t(i)-n*Ts)/Ts));
    end
end
figure(1)
subplot(2,1,1)
plot(t,x1)
hold on
stem(ts,x1resampled)
subplot(2,1,2)
plot(t,x1reconstructed)

代码的两个问题:

  1. 您没有正确累积重建样本。具体来说,您只保留了重采样信号中的一个值,而不是 all 个样本。

  2. sinc 在 MATLAB 中使用归一化的 sinc 函数。这意味着您不必将参数乘以 pi。回想一下,重建公式需要归一化的 sinc 函数,因此函数的参数中没有 pi 的乘法。

因此您只需更改 for 循环内的代码:

F1 = 300e6;
Fs = 800e6;
tmin = 0;
tmax = 10/F1;
t = tmin:1e-12:tmax;
x1 = cos(2*pi*F1*t);
Ts = 1/Fs;
ts = tmin:Ts:tmax;
x1resampled = cos(2*pi*F1*ts);
x1reconstructed = zeros(1,length(t)); %preallocating for speed
samples = length(ts);
for i = 1:1:length(t)
    for n = 1:1:samples
        x1reconstructed(i) = x1reconstructed(i) + x1resampled(n)*sinc((t(i)-n*Ts)/Ts); %%% CHANGE
    end
end
figure(1)
subplot(2,1,1)
plot(t,x1)
hold on
stem(ts,x1resampled)
subplot(2,1,2)
plot(t,x1reconstructed)

我现在得到这个情节:

为了提高效率,一定要使用 sum 函数,但要对所有样本执行此操作。所以你的 for 循环现在应该是:

for i = 1:1:length(t)
    x1reconstructed(i) = sum(x1resampled .* sinc((t(i) - (1:samples)*Ts) ./ Ts));
end

您可以使用离散傅里叶变换 (DFT) 完成同样的事情,但效率更高:

F1 = 300e6;
Fs = 800e6;
tmin = 0;
tmax = 10/F1;
t = tmin:1e-12:tmax;
x1 = cos(2*pi*F1*t);
Ts = 1/Fs;
ts = tmin:Ts:tmax;
x1resampled = cos(2*pi*F1*ts);

x1resampledDFT = fftshift(fft(x1resampled));
n = (length(x1)-length(x1resampledDFT))/2;
x1reconstructedDFT = [zeros(1,ceil(n)),x1resampledDFT,zeros(1,floor(n))];
x1reconstructed = ifft(ifftshift(x1reconstructedDFT));
x1reconstructed = x1reconstructed / length(x1resampled) * length(x1reconstructed);

figure(1)
subplot(2,1,1)
plot(t,x1)
hold on
stem(ts,x1resampled)
subplot(2,1,2)
plot(t,x1reconstructed)

这里发生的事情是我用零填充 DFT(使用 fft 有效计算)到所需的大小。然后,逆变换产生使用 sinc 插值器插值的信号。为了保持信号强度,需要进行一些归一化。您在 Rayryeng 的回答中看到的任何差异都是由于 DFT 的周期性性质造成的:基本上 sinc 函数,当它们离开右侧的信号域时,会在左侧返回;图右端的数据影响图左端的结果,反之亦然。

要了解有关使用傅里叶变换进行插值的更多信息,请参阅 this blog post