【问题标题】:How come when I zero-pad a signal the fft's of the orignal signal and the zero padded signal are no longer concatenated around the same point?当我对信号进行零填充时,为什么原始信号的 fft 和零填充信号不再围绕同一点连接?
【发布时间】:2019-04-10 19:25:19
【问题描述】:

我认为我执行代码错误。我认为原始信号和零填充信号将在同一点附近连接,具有相同的峰值。我对此的理解是错误的还是我的代码是问题所在?

clc;clear;
N=257; %number of points in the signal
f=330.5; %frequency of signal
fs=1024; %sampling frequency 
Ts=1/fs; %sampling period
ts=0:Ts:(N-1)/fs; %duration of signal
x=sin(f*ts);%generation of sampled signal
X=fftshift(fft(x)); %shifted FFT of signal
figure(5)
stem(abs(X))
M=2048; %number of points desired in the new signal that will be zero padded
zerovec=zeros(1,(M-N)); %creating enough 0's to add to the end of the original signal to achieve the desired length
x1=[x zerovec]; %concatenating original signal and 0's to get zero padded signal 
X1=fftshift(fft(x1)); %fft of zero padded signal

figure()
stem(abs(X)) %discrete plot of original signal
hold on 
stem(abs(X1)) %discrete plot of zero padded signal 

【问题讨论】:

    标签: matlab signal-processing fft dft


    【解决方案1】:

    当对信号进行零填充时,其频谱变得更加密集。从某种意义上说,当对空间域进行零填充时,您在频域中进行插值。

    如果您沿 x 轴绘制具有正确频率的两个频谱,您会看到它们重叠:

    N=257;
    f=330.5;
    fs=1024;
    Ts=1/fs;
    ts=0:Ts:(N-1)/fs;
    x=sin(f*ts);
    
    X=fftshift(fft(x));
    F=0:fs/N:fs-fs/N;     % <<< NEW!
    
    M=2048;
    zerovec=zeros(1,(M-N));
    x1=[x zerovec];
    X1=fftshift(fft(x1));
    F1=0:fs/M:fs-fs/M;    % <<< NEW!
    
    figure()
    stem(F,abs(X))        % <<< NEW! using F
    hold on 
    stem(F1,abs(X1))      % <<< NEW! using F1
    

    【讨论】:

    • 行得通!谢谢你的深思熟虑的解释
    猜你喜欢
    • 1970-01-01
    • 2016-06-25
    • 1970-01-01
    • 1970-01-01
    • 2012-07-09
    • 2021-05-30
    • 1970-01-01
    • 2018-06-27
    • 2021-04-22
    相关资源
    最近更新 更多