필터 지우기
필터 지우기

how can i add zero padding to DFT

조회 수: 1 (최근 30일)
Moshe
Moshe 2016년 5월 1일
답변: Star Strider 2016년 5월 1일
Hi all, i write code that doing DFT for signal see code here:
f0=46.875;
W0=2*pi*f0;
Fs=1000;
T=1/Fs;
NFFT=512;
FFTperiod=NFFT*T;
t=(0:NFFT-1)*T;
str=['FFT period is ',num2str(FFTperiod), ' seconds'];
Freq=10*1/FFTperiod
strFreq =['Frequency is ', num2str(Freq), ' Hz'];
Freqbin =1/FFTperiod
strFreqbin =['FFT frequency bin is ',num2str(1/FFTperiod), ' Hz'];
strFreqNyquist =['FNyquist is ',num2str(1/FFTperiod*512), ' Hz'];
disp(str);
disp(strFreq);
disp(strFreqbin);
disp(strFreqNyquist);
x_t=sin(W0*t);
subplot(3,1,1)
plot(t,x_t);
title('time domain signal')
xlabel('Time')
ylabel('Amplitude')
Y=fft(x_t,NFFT)/NFFT;
f=Fs/2*linspace(0,1,NFFT/2);
subplot(3,1,2);
plot(f,abs(Y(1:NFFT/2)))
title('freq domain')
xlabel('Hz')
ylabel('Amplitude')
To this code i want to plot new graph with zero padding on the signal, that Change the length of the series to 4096.
can some one advise me how to do it?

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 5월 1일
x=[1 2 3]
y=[x zeros(1,10-numel(x))]

Star Strider
Star Strider 2016년 5월 1일
Probably the best way is to use the nextpow2 function. See this documentation for fft for an illustration.

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by