how to claculate fft with window function?
233 ビュー (過去 30 日間)
古いコメントを表示
I saw several code implementation fft with window fcn.
size(window)
ans =
1 44100
size(z)
ans =
1 44100
% calculate fft
z = fft(s.*window);
or
size(x)
ans =
1 1001
size(winvec)
ans =
1001 1
xdft = fft(x'.*winvec);
How it should be calculated fft argument by column product or row product?
0 件のコメント
採用された回答
Star Strider
2022 年 11 月 9 日
The first is correct. Note that ‘s’ needs to be a column vector.
Fs = 1000;
L = 1E+4;
t = linspace(0, L-1, L).'/Fs; % Column Vector
s = sum(sin([1;100;200;300;400]*2*pi*t.')).'; % Column Vector
figure
plot(t, s)
grid
Fn = Fs/2;
NFFT = 2^nextpow2(L);
FTs = fft(s,NFFT)/L;
Fv = linspace(0, 1, NFFT/2+1)*Fn;
Iv = 1:numel(Fv);
figure
plot(Fv, abs(FTs(Iv)))
grid
xlabel('Frequency')
ylabel('Magnitude')
title('Without Window')
FTs = fft(s.*hamming(L),NFFT)/L;
figure
plot(Fv, abs(FTs(Iv)))
grid
xlabel('Frequency')
ylabel('Magnitude')
title('With Window')
.
2 件のコメント
Star Strider
2022 年 11 月 10 日
My pleasure!
The code creates a time vector and then a signal vector by summing the rows of ‘s’, creating column vectors.
A slightly easier approach would have been:
t = linspace(0, L-1, L)/Fs; % Row Vector
s = sum(sin([1;100;200;300;400]*2*pi*t)).' % Column Vector
t = t(:); % Column Vector
The (.') is the simple transpose operator, with (') being the complex conjugate transpose operator. For real arrays there’s no difference, however most of us here have gotten used to specifying the simple transpose and complex conjugate transpose to avoid the unintended consequences of using the complex conjugate transpose when we intended to use the simple transpoise.
.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Fourier Analysis and Filtering についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!