Is the window function automatically used when doing the fft function, or do I have to enter code to use the window function?

103 ビュー (過去 30 日間)
I used the fft function to make frequency measurements from the data.
At this time, I would like to know what the window function is using.
When using only the fft function, please tell me what kind of window function is used or if the window function is not applied
t = 0:0.01:1;
data = sin(2*pi*t);
plot(t,data)
fftdata = abs(fft(data));
% At this time, is the window function automatically used?
f = (0:length(data)-1)*1/length(data);
plot(f,fftdata)

回答 (1 件)

Star Strider
Star Strider 2023 年 1 月 27 日
The fft defaults to a rectangular window that is the length of the signal. That is the only one that is ‘autoomatically’ used. Any others would have to be provided specifically as part of the fft call.
There are several window funcitons available in the Signal Processing Toolbox.
Adding a Hanning window (the hann function) to your code would work like this —
t = (0:0.01:1).'; % Transpose To Column Vector
data = sin(2*pi*t);
plot(t,data)
L = numel(data)
L = 101
fftdata = abs(fft(data.*hann(L))); % Use Hanning Window
% At this time, is the window function automatically used?
f = (0:length(data)-1)*1/length(data);
plot(f,fftdata)
.
  2 件のコメント
正義 金田
正義 金田 2023 年 1 月 27 日
Thank you for teaching me carefully.
It was very helpful.
Star Strider
Star Strider 2023 年 1 月 27 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFourier Analysis and Filtering についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by