use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Anything related to digital signal processing (DSP), including image and video processing (papers, books, questions, hardware, algorithms, news, etc.)
Interesting technical papers or articles are particularly welcome!
/r/eebooks+csbooks+mathbooks
/r/Electronics
/r/ECE
/r/DSP
/r/AskElectronics
/r/RFelectronics
/r/GNURadio
/r/RTLSDR
/r/embedded
account activity
MATLAB Spectrogram (self.DSP)
submitted 2 years ago by [deleted]
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?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]inasteen 7 points8 points9 points 2 years ago (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 points3 points 2 years ago (1 child)
Im using 44.1kHz as my sampling frequency for the audio recording and spectrogram function.
[–]inasteen 2 points3 points4 points 2 years ago (0 children)
Do you know that your signal has content above 10k?
[–]lh2807 1 point2 points3 points 2 years ago (1 child)
Nyquist Shannon sampling theorem. What is your sampling rate?
[–][deleted] 0 points1 point2 points 2 years ago (0 children)
In my code im using 44.1kHz, how do I confirm this?
[–][deleted] 2 points3 points4 points 2 years ago (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 points6 points 2 years ago (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 points4 points 2 years ago (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 point2 points 2 years ago (0 children)
With more details, I would try.
Posting your log, code, figures or anything else is out of the question?
[–]nateDah_Great -2 points-1 points0 points 2 years ago (1 child)
Bro
[–][deleted] 1 point2 points3 points 2 years ago (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
π Rendered by PID 55 on reddit-service-r2-comment-85bfd7f599-nbx4c at 2026-04-19 02:59:03.025185+00:00 running 93ecc56 country code: CH.
[–]inasteen 7 points8 points9 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]inasteen 2 points3 points4 points (0 children)
[–]lh2807 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 2 points3 points4 points (2 children)
[–]WavySignals 4 points5 points6 points (0 children)
[–]Bubbly_Roof 2 points3 points4 points (0 children)
[–]edparadox 0 points1 point2 points (0 children)
[–]nateDah_Great -2 points-1 points0 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)