フィルターのクリア

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 Center および File ExchangeFourier Analysis and Filtering についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by