How to implement rectangular and welch window in MATLAB to plot fft respectively?

5 Ansichten (letzte 30 Tage)
Hello Everybody,
I just want to know that how to implement rectangular and welch window in MATLAB to plot fft? And i want to know that what will be the effect if i do not use these in our fft? I have written the following code so please suggest how to specify rectangular and welch window in this code.
I = load('data1.asc');
for i = 1:2048
x = I(:,2);
end
Fs = 40;
t = 0:1/Fs:(2e3*1/Fs)-1/Fs;
T = 1/Fs;
L = 2048;
NFFT = 2^nextpow2(L);
Y = abs(fft(x,NFFT))/L;
f = Fs/2*linspace(0,1,NFFT/2+1);
plot(f,2*abs(Y(1:NFFT/2+1)))
axis([0 50 0 40])

Antworten (2)

Honglei Chen
Honglei Chen am 23 Jul. 2013
Rectangular window is the same as no window. For Welch window, you can find it on file exchange at
(Disclaimer: I haven't personally used it so I cannot comment on its quality)
If you have a window, w, you just need to do the following in your code instead:
Y = abs(fft(x.*w,NFFT))/L;

Deyan Dobromirov
Deyan Dobromirov am 7 Feb. 2021
The implementation fails to create zeros at both ends. Here is my version:
function w = welchwin(n)
m = floor(n/2); k = (0:m-1)';
w = 1 - (2*k/n - 1).^2;
if(mod(n, 2) ~= 0), w = [w; 1]; end
w = [w; flipud(w(1:m, 1))];
end

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by