필터 지우기
필터 지우기

how to claculate fft with window function?

조회 수: 258 (최근 30일)
Jack Daniels
Jack Daniels 2022년 11월 9일
댓글: Star Strider 2022년 11월 10일
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개)

카테고리

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

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by