how to claculate fft with window function?

215 次查看(过去 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?

采纳的回答

Star Strider
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 个评论
Jack Daniels
Jack Daniels 2022-11-10
Can be written somehow differently?
t = linspace(0, L-1, L).'/Fs; % Column Vector
s = sum(sin([1;100;200;300;400]*2*pi*t.')).'; % Column Vector
It seems unreadable ... " .' " - what that mean in the of the statement?
Thanks for explanantion.
Star Strider
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 个)

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by