Using Spectrogram to check whether aliasing will occur

I was wondering if the spectrogram can be used as a MATLAB tool to check whether or not aliasing will occur when the signal is downsampled from let's say, 44.1kHz to 8kHz? And if yes, how do I go about it?

• Sure - use the spectrogram to check whether you have any energy above 4 kHz - if you do then you need to filter before resampling. – Paul R Sep 4 '12 at 8:48
• Thanks for the reply. Please correct me if I'm wrong. My original fs = 44.1kHz and my desired fs = 8kHz. So, my spectrogram code line should be spectrogram ( signal, 256, 224, 1024, original_fs, 'yaxis' ); Am I right? or should I use the desired_fs in my spectrogram codeline instead? Thanks! @PaulR – sakuragurl Sep 4 '12 at 11:11
• That's probably OK, but you can experiment with the parameters until you get a spectrogram that you're happy with: mathworks.co.uk/help/toolbox/signal/ref/spectrogram.html. Note that the sample rate is only used for labelling the Y axis. Use original_fs to see where the energy is in the original signal. If you have anything above the 4 kHz line then you need to filter before resampling. – Paul R Sep 4 '12 at 11:16
• Oh I see. Thank you so much for your help @PaulR! :) – sakuragurl Sep 4 '12 at 11:40
• Why are you not checking the DFT of the entire signal? Is there a specific reason you want to use a spectrogram and not a straightforward FFT? – Phonon Sep 4 '12 at 16:28

If the spectrogram displayed is sensitive enough to show spectral energy from half the old sample rate to half the new sample rate (e.g. anything at or between 4 kHz to 22.05 kHz), that energy will be aliased unless low-pass filtered out before or during downsampling (to 8KHz). If there is nothing there, then there is nothing that will be aliased by properly interpolated (Sinc kernel, et.al) downsampling without any further low-pass filtering (such as a wider windowed Sinc FIR kernel, etc.)

• I see. Thanks for the detailed explanation :) – sakuragurl Sep 6 '12 at 5:10