【发布时间】: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