Borrar filtros
Borrar filtros

how to claculate fft with window function?

215 visualizaciones (últimos 30 días)
Jack Daniels
Jack Daniels el 9 de Nov. de 2022
Comentada: Star Strider el 10 de Nov. de 2022
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?

Respuesta aceptada

Star Strider
Star Strider el 9 de Nov. de 2022
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 comentarios
Jack Daniels
Jack Daniels el 10 de Nov. de 2022
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 el 10 de Nov. de 2022
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.
.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by