why does spectrogram of stft shows different magnitude while changing the window size?
Mostrar comentarios más antiguos
fs=5000; % Sampling rate
N=1000; % Number of data points
y=sin(500*pi*[0:1:N-1]/fs)...
+2*sin(500*1.5*pi*[0:1:N-1]/fs)...
+3*sin(500*3*pi*[0:1:N-1]/fs)...
+4*sin(500*4*pi*[0:1:N-1]/fs);t=[0:1:N-1]/fs;
figure(1);
windowsize = 200;
window = boxcar(windowsize);
nfft = windowsize;
noverlap = windowsize-1;
[S,F,T] = spectrogram(y,window,noverlap,nfft,fs);
imagesc(T,F,(abs(S)))
set(gca,'YDir','Normal')
xlabel('Time (secs)')
ylabel('Freq (Hz)')
title('Short-time Fourier Transform spectrum')
For the above signal, the expected amplitudes of frequencies are in the range 1-4. once we i do the stft with window size 200, i am getting amplitudes of frequency in the range of 0-400 Hz. if i reduce the window size to 16, the amplitudes moving to the range of 0-45 Hz. Did i do anything wrong in my code or am i conceptually wrong somewhere?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Get Started with Signal Processing Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!