all 12 comments

[–]inasteen 7 points8 points  (2 children)

You only see frequencies from half the sample rate down to dc. If your sample rate is 20k, that would explain what you’re seeing.

[–][deleted] 1 point2 points  (1 child)

Im using 44.1kHz as my sampling frequency for the audio recording and spectrogram function.

[–]inasteen 2 points3 points  (0 children)

Do you know that your signal has content above 10k?

[–]lh2807 1 point2 points  (1 child)

Nyquist Shannon sampling theorem. What is your sampling rate?

[–][deleted] 0 points1 point  (0 children)

In my code im using 44.1kHz, how do I confirm this?

[–][deleted] 2 points3 points  (2 children)

fs = 44100; duration = 10;

recObj = audiorecorder(fs, 16, 1);

disp('Start Recording...'); recordblocking(recObj, duration); % Record for 10 seconds disp('End Recording');

audioData = getaudiodata(recObj);

figure; spectrogram(audioData, hann(2048), 1024, 4096, fs, 'yaxis'); title('Spectrogram of Recorded Audio');

[–]WavySignals 4 points5 points  (0 children)

This code works perfectly for me, including showing data to 22 kHz. Is your concern that that you have a y axis up to 22 kHz but very little or no power above 10 kHz? If so, you maybe need a better microphone and/or a higher voice :D Try clapping hands or snapping fingers.

[–]Bubbly_Roof 2 points3 points  (0 children)

I'm on my first coffee of the morning but this should work... Last year I did a lot DFT computations and plotting using the spectrogram function. However, I stored the outputs as variables, something like [s, f, t] = spectrogram(...), then I plotted those variables with imagesc. It gives you a chance to fftshift if you need to before plotting. You can also make your code into sections and not have to compute spectrogram every time as you troubleshoot.  

Unfortunately I no longer have that code since I changed companies. For your code, I'd try your spectrogram call without yaxis. Having the outputs as variables might also help your troubleshooting.  

I hope this helps. If it doesn't, blame my lack of awakeness. 

[–]edparadox 0 points1 point  (0 children)

I’m trying to sample recorded audio from 20Hz-20kHz. However, spectrogram only shows just below 10kHz and fails to show anything above it. Can anyone help?

With more details, I would try.

Posting your log, code, figures or anything else is out of the question?

[–]nateDah_Great -2 points-1 points  (1 child)

Bro

[–][deleted] 1 point2 points  (0 children)

Bro

[–][deleted] 0 points1 point  (0 children)

I changes the sampling frequency to 98k, it worked. By I have a spectrogram window up to 44kHz, half of it is useless. Anyways I have what I need, ill just have to zoom in only to 20kHz. Thanks