필터 지우기
필터 지우기

correct way for zero padding

조회 수: 7 (최근 30일)
Kutru biladi
Kutru biladi 2015년 8월 31일
편집: per isakson 2015년 8월 31일
Here in the code below, I am taking fft of my data and plotting it. Moreover, I am doing zero padding by multiplying the signal length by 1000.
Is it the correct way for Zero padding? Moreover, am I defining frequency axes correctly? I am not getting desired output. Thanks everyone in advance
% second-order butterworth
[b, a] = butter(2, [w1 w2], 'bandpass');
load('fb2030'); % loading the data
x = fb2030(30,:);
% filtering
y_filt = filter(b,a,x); % filtering the received signal
nfft = length(y_filt)*1000; %%%%Zero Padding
res = fft(y_filt,nfft)/ nfft; % normalizing the fft
%
f = fs/2*linspace(0,1,nfft/2+1); % choosing correct frequency axes
res = res(1:nfft/2+1); % amplitude of fft(taking the half length of nfft)
figure,plot(f,2*abs(res));
xlabel('Frequency in MHz');ylabel('amp')
  댓글 수: 1
dpb
dpb 2015년 8월 31일
By nfft = length(y_filt)*1000; you've caused a length of 1000X the actual length of your signal so only a small fraction N/(N*1000+N) or just under 0.1% of the signal being transformed is nonzero.
The typical zero-padding is to the next power of 2 over the length but that is mostly a remnant of years ago when compute power was much less and the difference in speed of the algorithm was a serious concern. Now if the signal is of sufficient length to have reasonable resolution, you may well do without padding at all.
But see
doc fft
doc nextpow2
for sample of doing a PSD

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by