extract max and min frequency of a spectrum

How Determine the bandwidth as well as the minimum and maximum frequency of each audio channel by writing a Matlab code?

 Accepted Answer

There are some Signal Processing Toolbox functions that may do what you want.
See for example the powerbw function. There are similar functions linked to it in the See Also section of its documentation.

5 Comments

Let us experiment with some actual audio.
load handel
Fs
Fs = 8192
powerbw(y, Fs)
ans = 0.0618
If we use a cutoff of -50 dB then we still get peaks at around 3.2 kHz. But those peaks are barely differentiated from the rest of the signal, so it is not clear that they are meaningful. A cutoff of -45 dB would pick up the peak near 2.25 kHz that is possibly more meaningful.
But it is not clear why we should choose -45 dB before-hand. It would be more clear if we choose -30 dB before-hand. Which would select for about 0.525 kHz and 1.15 kHz . However, clearly filtering out anything outside that range would lose a lot of meaning in the signal.
As always, my pleasure!

Sign in to comment.

More Answers (1)

You could fft(), and take the first half of the results, and find the last bin such that abs(BIN)>0 . That last bin will correspond to the highest frequency. Likewise, the first such bin (other than the very first bin) with abs()>0 corresponds to the minimum frequency.
However... fft() is prone to round-off errors, and there is a high chance of numeric noise. So you want abs(BIN)>TOLERENCE to ignore the numeric noise.
But... in practice, if the audio was not created by ifft(), then chances are high that abs(BIN) is non-zero for extended periods. Real audio seldom represents a repeating signal, and the effect of silence is to effectively add a sinc() signal to the fft, so the high frequency bins of fft of real audio almost always have non-zero content.

Community Treasure Hunt

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

Start Hunting!